blinry / nom

"Lose weight and hair through stress and poor nutrition"
GNU General Public License v2.0
64 stars 4 forks source link

fix evaluation order when detecting cmd_name #11

Closed rohieb closed 1 year ago

rohieb commented 2 years ago

Apparently the '=' operator binds stronger than the 'or' operator:

$ irb
irb(main):001:0> array = []
=> []
irb(main):002:0> cmd_name = array.shift or "status"
=> "status"
irb(main):003:0> cmd_name.inspect
=> "nil"
irb(main):004:0> cmd_name = (array.shift or "status")
=> "status"
irb(main):005:0> cmd_name.inspect
=> "\"status\""

Put a pair of braces around it to fix the order.

blinry commented 1 year ago

Oh interesting! That must've changed with some Ruby version! Thanks for the fix!