Answers for "what does gets do in ruby"

0

How do you use gets in Ruby

#lets say you want to get the name of the user
#The language used here is "ruby" for your kind info.


name=gets #name is the variable, and "gets" is the function used for that

print "Hello"<<name #Concatinating the strings "Hello" and whatever the user entered.

=begin

Other ways for concatinating:

"Hello"+name
"Hello".concat(name)

or,

string_to_print="Hello"
string_to_print+=name

print string_to_print
=end
Posted by: Guest on January-30-2021

Browse Popular Code Answers by Language