Ruby String Operators - waltdakind/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 -
.concatmethod
-
"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 |