News for hackers. Stuff that matters.
Re:Read this post ‘unless’ you’re not a Ruby developer by ilyt on Tuesday December 13, 2022 @09:18AM (#33969158)
and why

    def my_method(required_thing)
      raise 'required_thing is required' if !required_thing.present?
is a problem ?
Re:Read this post ‘unless’ you’re not a Ruby developer by lucidone on Tuesday December 13, 2022 @10:13AM (#33969882)
I 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".