Answers for "best way to concatenate strings in ruby"

1

string concatenation in Ruby

#lets get 2 strings from user first

first_name = gets
last_name = gets

#Now concatentate the strings

first_name.concat(last_name)

=begin
Other ways for concatenating string:

last_name.prepend(first_name)
first_name<<last_name
first_name+=last_name

=end

#Now printing

print "Hey, "+first_name+", hope you are doing well"

=begin
Others ways for this:

print "Hey, "<<first_name+", hope you are doing well"


There can be many more ways of doing the same thing. Go ahead and explore what
you like the most.
=end
Posted by: Guest on January-30-2021

Code answers related to "best way to concatenate strings in ruby"

Browse Popular Code Answers by Language