On Fri, May 18, 2007 at 11:24:19PM +0900, Sebastian Hungerecker wrote:
> jim o wrote:
> > I am new to Ruby, and trying to find a good ref as for when one would use
> > the form
> >
> >     puts #{a}
> > vs
> >     puts a
> 
> puts #{a} doesn't do anything (except return nil), so I'm going to assume you
> meant to say puts "#{a}". Since that does the same thing as puts a but is more
> to type, I'd always use the latter. The #{} syntax is only useful when you
> want to print out more than just the content of the variable. For example:
> puts "The value of x is #{x}"

It really takes a more complex example to really make using that syntax
worthwhile.  After all, these are equivalent:

  puts "The value of foo is #{foo}"
  puts "The falue of foo is " + foo

. . . except that the second example doesn't require as much use of the
Shift key.

Yeah, though -- your example does make the point clear.  I guess I'm
just being a touch pedantic.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
Ben Franklin: "As we enjoy great Advantages from the Inventions of others
we should be glad of an Opportunity to serve others by any Invention of
ours, and this we should do freely and generously."