Created
August 19, 2014 20:35
-
-
Save k0nserv/633bcc3ea2ff0ee4bc2d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Define the ++= operator | |
infix operator ++= {} | |
func ++= (action: @autoclosure () -> (), condition: BooleanType){ | |
unless(condition, action) | |
} | |
var x = 1 | |
// This is equal to ruby's | |
// x = 2 unless 1 > 2 | |
(x = 2) ++= 1 > 2 | |
println("\(x)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment