[lazy@localhost chapter1]$ vim chapter1_6.rb
# Instance for Input and Output
puts "Input your name please:"
name = gets
puts "Hello," + name + ",welcome to our home."
puts "Input your name please:"
name = gets.chomp # remove the ‘\n’ from gets
puts "Hello," + name + ",welcome back home."
[lazy@localhost chapter1]$ ruby chapter1_6.rb
Input your name please:
lazy
Hello,lazy
,welcome to our home.
Input your name please:
lazy
Hello,lazy,welcome back home.
[lazy@localhost chapter1]$ vim chapter1_7.rb
# Instance for output function
name = gets.chomp
puts "Hello," + name + ",welcome to ruby world.\n"
print "Hello," + name + ",welcome to ruby world.\in"
printf("Hello,%s,welcome to ruby world.\n",name) # Normal output
printf("Hello,%6s,welcome to ruby world.\n",name) # Right align
printf("Hello,%-6s,welcome to ruby world.\n",name) # Left align
[lazy@localhost chapter1]$ ruby chapter1_7.rb
lazy
Hello,lazy,welcome to ruby world.
Hello,lazy,welcome to ruby world.
Hello,lazy,welcome to ruby world.
Hello, lazy,welcome to ruby world.
Hello,lazy ,welcome to ruby world.