The command (yes consider it a command in this sense) puts does not accept
the same formatting syntax as printf and sprintf. Does that help you?
Another variation and interface to consider with puts is:

puts "So you are " + age + "years old."

~Stu



On Thu, Feb 6, 2014 at 7:09 PM, Kaustubh Chaudhari <lists / ruby-forum.com>wrote:

> Hi All,
>
> Sorry if i am bothering you all with a silly question. I am new to
> programming itself not just to ruby.
>
> print "what is your age? "
> age = gets.chomp()
> puts "So you are %s years old.", %age
>
> This is not working as expected. It is erroring out  "unterminated
> string
> meets end of file"
>
> However if i use below line it works.
>
> puts "So you are #{age} years old.
>
> I am trying to understand the difference and reason behind this.
>
> Any help is appreciated!
>
> -Kaustubh
>
> --
> Posted via http://www.ruby-forum.com/.
>