Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Ignores `value` and just evaluates `pattern`.
- /// Can be used to evaluate arbitrary expressions in a switch.
- func ~=<A>(pattern: @autoclosure () -> Bool, value: A) -> Bool {
- return pattern()
- }
- let (x, y, z) = (0, 0, 1)
- switch () /* can be anything */ {
- case x > 0: print("x matches")
- case y < 0: print("y matches")
- case z == 1: print("z matches")
- default: print("no match")
- }
Add Comment
Please, Sign In to add comment