RosettaCodeData/Task/String-concatenation/Ruby/string-concatenation.rb

11 lines
305 B
Ruby
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
s = "hello"
2014-01-17 05:32:22 +00:00
p s + " literal" #=> "hello literal"
2013-04-11 01:07:29 -07:00
s1 = s + " literal"
2014-01-17 05:32:22 +00:00
p s1 #=> "hello literal"
2013-04-11 01:07:29 -07:00
s1 << " another" # append to s1
2014-01-17 05:32:22 +00:00
p s1 #=> "hello literal another"
s = "hello"
p s.concat(" literal") #=> "hello literal"
p s #=> "hello literal"