Skip to content

Instantly share code, notes, and snippets.

@caffo
Created January 10, 2012 14:29
Show Gist options
  • Save caffo/1589347 to your computer and use it in GitHub Desktop.
Save caffo/1589347 to your computer and use it in GitHub Desktop.
unless := method(
(call sender doMessage(call message argAt(0))) ifFalse(
call sender doMessage(call message argAt(1))) ifTrue(
call sender doMessage(call message argAt(2)))
)
unless(1 == 2, write("One is not two\n"), write("one is two\n"))
@jmcarthur
Copy link

In Haskell:

unless p a b = if p then b else a

If if was just a function instead of special syntax (or one had defined a function with the same behavior), it could look like this:

unless = if . not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment