Tuesday, February 18, 2014

User input in Ruby

This is a sample program which takes user input and prints the same in Ruby

HI..!! enter ur name please: Test User
Hello Test User
view raw output hosted with ❤ by GitHub
print('HI..!! enter ur name please: ')
name = gets()
puts("Hello #{name}")
#this symbol is mainly used for comments.. what role is it playing here..??
# the hash symbol in the puts stmnt above within quotes can be used to print the value of the entity within the quotes
puts("\n")
#<<name


No comments:

Post a Comment