inserting value of a variable in a string : String Concatenation « String « Ruby






inserting value of a variable in a string


person = "Matz!"
puts "Hello, #{person}" # => Hello, Matz!

 








Related examples in the same category

1.Append one string to another with the + method:
2.append a string with the << method:
3.Concatenate (join) strings together, using a +
4.Using the + symbol concatenates the two strings "
5.Push several strings into one
6.Encode command in string