News for hackers. Stuff that matters.
Re:Reverse Engineering One Line of JavaScript by coldtea on Friday July 14, 2017 @05:29AM (#14768607)
While the main complain might be valid, I disagree about the quick initializer.

It's much cleaner, doesn't pollute the code with extra stuff not pertinent to the problem (if, end), and keeps it straight to the point.

It's not at all different to tons of other constructs, like:

  x += 1;
or:

  i++;
Re:Reverse Engineering One Line of JavaScript by jbg_ on Friday July 14, 2017 @09:44AM (#14769713)
Unfortunately, it's not actually an initialiser. Type confusion is really common in Ruby programs, sadly.

The construct in parent assigns 1 if foo is "falsey", not strictly if it is nil. Even if foo is already initialised but contains a "falsey" value it will be assigned 1.

Re:Reverse Engineering One Line of JavaScript by stevedt on Friday July 14, 2017 @10:52AM (#14770203)
But in Ruby only false and nil are "falsey", so unless the variable was accidentally set to false (not impossible) the construct behaves as an initializer.