Hi!

Now also tested on MRI:

x=1; y=2

x,y=y,x

How to correctly puts (x,y=y,x) ?

(displaying it shouldnt change the result of the assignment...)

I would expect to see the results [2,1]

Thank you

Berg

Hi!

Now also tested on MRI:

x=1; y=2

x,y=y,x

How to correctly puts (x,y=y,x) ?

(displaying it shouldnt change the result of the assignment...)

I would expect to see the results [2,1]

Thank you

Berg

You want to see the same thing as if:

tmp = [y,x]

puts tmp

Try this:

x=1; y=2

puts((x,y=y,x)) # one set of parentheses for the arguments to puts, one to contain the single argument

You're correct in that the "value" of the expression:

x,y=y,x

is the same as the RHS (right-hand side)

Also, know that puts will put each item from an array on a line.

Perhaps you want:

x=1; y=2

p((x,y=y,x))

if you expect the output to look like an array.

-Rob

On 2016-Aug-9, at 16:57 , A Berger <aberger7890@gmail.com> wrote:

Hi!Now also tested on MRI:

x=1; y=2

x,y=y,x

How to correctly puts (x,y=y,x) ?

(displaying it shouldnt change the result of the assignment...)

I would expect to see the results [2,1]Thank you

Berg