concept conditional test in category ruby

appears as: conditional tests, conditional tests, conditional test
The Well-Grounded Rubyist, Third Edition

This is an excerpt from Manning's book The Well-Grounded Rubyist, Third Edition.

Assignment in a conditional test

In this example, note that the conditional test is an assignment (x = 1) and not an equality test (which would be x==1):

As always, you could rewrite the assignment and the conditional test like this:

m = /la/.match(name)
if m
  # etc.

You don’t have to combine them into one expression. But at least in this case there’s some semantic weight to doing so: the expression may or may not pass the conditional test, so it’s reasonable to test it.