4 ms·
raise "Hey dude! Where's My Variable Assignment" if my_variable.nil? I really hate raising an exception like that. I am surprised Rubyists like it like he says
by sigzero 16y ago
raise "Hey dude! Where's My Variable Assignment" if my_variable.nil?
I really hate raising an exception like that. I am surprised Rubyists like it like he says they do.
- substack 16y agoI prefer: my_variable or raise 'Hey dude! Where's My Variable Assignment' or else: my_variable.nil? and raise 'Hey dude! Where's My Variable Assignment' since it puts what's being tested in front like with if/then but is also syntactically light-weight.
- robconery 16y agoI could be completely wrong - I do like the "or" syntax as well - reads much better.