From: Gavin Sinclair Date: 2012-02-01T20:49:47+09:00 Subject: Re: Multiple assignment in conditional On Tue, Jan 31, 2012 at 6:22 PM, Josh Cheek wrote: >> # The following causes a SyntaxError: multiple assignment in conditional. >> if (a, b = foo) >>  puts a >> end > What did you expect your real code to do? It seems to me that it should > raise an error unless it's an array of size 2 Nope. It can return anything at all and Ruby will deal with it. Parallel assignment is (thankfully) flexible. def foo; 1; end a, b = foo # returns 1; a == 1, b == nil def bar; [1,2,3,4,5]; end a, b = bar # returns [1,2,3,4,5]; a == 1, b == 2 > and if it is, then it should > return an array of size two, making the conditional necessarily true. Nope. The conditional can be false. def foo; nil; end a, b = foo # returns nil; a == nil, b == nil > So I don't know what you were expecting to happen. def foo; nil; end if (a, b = foo) puts "outcome 1" else puts "outcome 2" # I was expecting this. end Of course I don't have a function that returns nil unconditionally! Just showing the structure.