Issue #10450 has been updated by Matthew Kerwin.


bug hit wrote:
> 
> Good point about the dust.  There are three entries in this bug that are essential, my initial report, Alex Boyd's patch, and Yusuke Endoh's historical explanation.  All of your posts are indeed dust that can and should be removed, try to resist the urge to dust this bug any further.
> 
> There are not two issues here, just one, multiple assignment in conditionals is not possible. In the first post I provided examples to show that the problem is present with and without parens (with different errors), that's a good thing, makes the bug report more thorough.
> 
> What horror, the confusion of absorbing two related facts instead of one, why, it's enough make your brain seize up.

I've watched this thread with interest, followed by amusement, and finally disappointment. I could write tomes about the Ruby community's values, about what can be gained by being polite to respected members of the Ruby community (not to mention the rest of us), and the value of taking advice or direction from said community members, but apparently that wouldn't contribute in any meaningful way -- it would only be so much dust.

However I must raise a point of order:

> that's a good thing, makes the bug report more thorough.

In this case it was apparently a bad thing, and made the bug report confusing. What is good in some development communities isn't necessarily good in Ruby, and confusing Matz is just about the worst thing you can do here. (Not to mention insulting his intelligence.)

The best way to get what you want is to listen to people, be patient, and be nice. MINSWAN.

</meta-discussion>

----------------------------------------
Bug #10450: multiple assignment in conditional
https://bugs.ruby-lang.org/issues/10450#change-50487

* Author: bug hit
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
multiple assignment is an expression whose value can be truthy (array) or falsy (nil, false), so why is there a restriction on its use in conditionals?  A warning perhaps is justified, but a syntax error, why?


irb(main):001:0> if a, b = nil then 1 else 0 end
SyntaxError: (irb):1: syntax error, unexpected ',', expecting keyword_then or ';' or '\n'
if a, b = nil then 1 else 0 end
     ^
(irb):1: syntax error, unexpected keyword_then, expecting end-of-input
if a, b = nil then 1 else 0 end
                  ^
	from /home/alex/.rbenv/versions/2.1.4/bin/irb:11:in `<main>'
irb(main):002:0> if (a, b = nil) then 1 else 0 end
SyntaxError: (irb):2: multiple assignment in conditional
	from /home/alex/.rbenv/versions/2.1.4/bin/irb:11:in `<main>'
irb(main):003:0> (a, b = nil) ? 1 : 0
SyntaxError: (irb):3: multiple assignment in conditional
	from /home/alex/.rbenv/versions/2.1.4/bin/irb:11:in `<main>'
irb(main):004:0> (a, b = nil)
=> nil




-- 
https://bugs.ruby-lang.org/