Ruby String Operators - ashish9342/FreeCodeCamp GitHub Wiki
Both concatenation and multiplication can be performed on strings.
-
Strings can be joined together using any of the following methods:
-
+
operator -
<<
operator -
.concat
method
-
"Hello" + " World" + "!"
# returns:
Hello World!
"Hello" << " World!"
# returns:
Hello World!
string1 = "Hello"
string2 = " World!"
string1.concat(string2)
# returns:
Hello World!
- Strings can be multiplied by an integer value using the
*
operator.
"Hello" * 3
# returns:
HelloHelloHello
Previous | Home | Next |
---|---|---|
Ruby Basics | Table of Contents | Ruby String Methods |