3 ms·
and why def my_method(required_thing) raise 'required_thing is required' if !required_thing.present? is a problem ?
by ilyt 4y ago
and why
def my_method(required_thing)
raise 'required_thing is required' if !required_thing.present?
is a problem ?
- lucidone 4y agoI don't think it's a problem necessarily. "unless" is more obvious to me since since it visually stands out more than "if !required_thing" while I'm casually scanning the code. So, in practice, it acts as an indication from the author of the code to the reader that "this line of code is a guard since we're using an unless".