code
register
log in
programs
messages
download
about
privacy
terms
french
production
home
/
documentation
/
String
examples
hello world
input
"hello world"
result
"hello world"
one to string
input
1.to_string
result
"1"
symbol to string
input
:hello
result
"hello"
string new hello
input
String.new(:hello)
result
"hello"
hello days from now
input
"hello {2.days.from_now}"
result
"hello 2025-06-23 18:23:04 UTC"
instance functions
&
examples
map with ampersand self symbol
input
[1, 2, 3].map(&:self)
result
[1, 2, 3]
*
examples
ruby symbol multiplication
input
:abc * 3
result
"abcabcabc"
+
examples
concatenation using symbols
input
:abc + :def
result
"abcdef"
symbol concatenation with number
input
:abc + 1
result
"abc1"
concatenation with array
input
:abc + [1, 2, 3]
result
"abc[1, 2, 3]"
downcase
examples
downcase
input
:aBc.downcase
result
"abc"
first
examples
symbol first
input
:abc.first
result
"a"
include?
examples
symbol include check
input
:abc.include?(:bc)
result
true
symbol include check not found
input
:abc.include?(:e)
result
false
parameterize
examples
string manipulation
input
"hello world".parameterize
result
"hello-world"
reverse
examples
symbol reverse function example
input
:abc.reverse
result
"cba"
substitute
examples
symbol substitute bc with empty string resulting in aa
input
:abcbca.substitute(:bc)
result
"aa"
replace bc with de resulting in adedea
input
:abcbca.substitute(:bc, :de)
result
"adedea"
to_function
examples
map self
input
[1, 2, 3].map(:self.to_function)
result
[1, 2, 3]