First off, great post! I was worried at first that "David" was going to be unnecessarily critical of your PR, but it's awesome that his comments brought you to a number of useful refactors, and even better that you shared what you learned to help other new developers 😁
There's a subtle gotcha case with the or-assign operator, but it shouldn't occur in the context of this loop: let's say you have
The or-assign operator will take the falsey value* at something[:some_variable] and replace it with true. Similarly, the &&= operator will reassign variables that are truthy* (useful for cases like when you want to update values in a hash, but only if they already exist … and aren't false 😅)
*Rubyists love expressing ourselves in almost-words. falsey and truthy describe values that the double-negative patten will cast as !!foo == false and !!bar == true, respectively.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
First off, great post! I was worried at first that "David" was going to be unnecessarily critical of your PR, but it's awesome that his comments brought you to a number of useful refactors, and even better that you shared what you learned to help other new developers 😁
There's a subtle gotcha case with the or-assign operator, but it shouldn't occur in the context of this loop: let's say you have
The or-assign operator will take the falsey value* at
something[:some_variable]
and replace it withtrue
. Similarly, the&&=
operator will reassign variables that are truthy* (useful for cases like when you want to update values in a hash, but only if they already exist … and aren'tfalse
😅)*Rubyists love expressing ourselves in almost-words.
falsey
andtruthy
describe values that the double-negative patten will cast as!!foo == false
and!!bar == true
, respectively.