I have a variable that will have the following values:
blah = # 1, 0, or -1
Now I want to set these two variables:
up
down
To either 1 or 0 based on the value of ‘blah’.
If blah is 1, then up = 1 and down = 0, if blah is -1 then down = 1 and up = 0
If blah is 0, then both are 0.
How can you do this the ruby way w/o so many if checks?
Solution 1
Solution 2 (Inspired by mu is too short)