To prepend a string to the beginning of another string in Ruby, you can use the prepend
method or the +
operator. Here are examples of both methods:
main.rb179 chars10 lines
Both of these methods will produce the same result, which is Hello world
.
The prepend
method adds the string at the beginning of the receiver, while the +
operator join both strings, returning a new string that has the combined value of both.
gistlibby LogSnag