News for hackers. Stuff that matters.
Re:If-then-else had to be invented by m463 on Sunday December 13, 2020 @04:54PM (#25410727)
I like the use of language in perl and wish it was more prevalent in other languages.

For example instead of saying "if not <condition>" you can also say "unless <condition>" which is more natural imo.

Re:If-then-else had to be invented by hnick on Sunday December 13, 2020 @06:43PM (#25411666)
Yes it's a weird feature but I found myself drawn to it. Just like with natural language, sometimes the 'unless' keyword feels like a better fit.

Both keywords work in postfix form, and this is how I usually use 'unless' so it reads more like a sentence.

  do_thing() unless ($a == 1);
  do_thing() if ($a != 1);
Re:If-then-else had to be invented by Can_Not on Sunday December 13, 2020 @09:27PM (#25412854)
This is valid in crystal:

    unless a
        a = 4
    end
    return x unless y
    return z