Created
January 10, 2012 14:29
-
-
Save caffo/1589347 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) |
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
@jeremytregunna: I'm referring to the (syntax of the) Scala example provided:
println("flag is " + flag) unless flag