ways to concat on ruby code example

Example: 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

Tags:

Ruby Example