You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a confession… I don’t like unless — I find it confusing as I have to negate an if statement in my head.
A variation of unless that I really like is Swift’s guard. It’s essentially a check with an early return. Unless the guard’s condition is true, it then forces you to return on the else.
guard len >0else{return false
}
Here’s what it could look like with Orb:
# Rather than:unlesslen>0doreturn(0)end# Instead write:guarddolen>0elsereturn(0)end
I’d be open to using unless if there’s some way to make it more readable.
Note that WebAssembly doesn’t have the concept of unless, only Elixir does. So I don’t see adding a new concept that WebAssembly doesn’t have like guard as that much more of mortal sin than adding unless.
Alternatives
unless(len>0,return: 0)
return(0whennotlen>0)
The text was updated successfully, but these errors were encountered:
I have a confession… I don’t like
unless
— I find it confusing as I have to negate anif
statement in my head.A variation of
unless
that I really like is Swift’sguard
. It’s essentially a check with an early return. Unless the guard’s condition is true, it then forces you to return on theelse
.Here’s what it could look like with Orb:
I’d be open to using
unless
if there’s some way to make it more readable.Note that WebAssembly doesn’t have the concept of
unless
, only Elixir does. So I don’t see adding a new concept that WebAssembly doesn’t have likeguard
as that much more of mortal sin than addingunless
.Alternatives
The text was updated successfully, but these errors were encountered: