Sebastian Hungerecker
9/5/2007 11:50:00 AM
Z T wrote:
> When I run my program:
>
> arg1="Ruby", arg2="Rails", arg3="Rails"
> puts "#{arg1}, #{arg2}, #{arg3}"
>
> Why is the output as follow:
> RubyRailsRails, Rails, Rails
>
> What is the reason for this output? Thanks in advance.
In Ruby x=1,2,3 is the same as x=[1,2,3].
x,y,z=1,2,3 (or x,y,z=[1,2,3]) is the same as x=1; y=2; z=3.
Your code is interpreted as arg1=["Ruby", arg2="Rails", arg3="Rails"]
and since assignments evaluate to the assigned value arg1 now is
["Ruby", "Rails", "Rails"].
HTH,
Sebastian
--
Jabber: sepp2k@jabber.org
ICQ: 205544826