Last active
December 4, 2015 14:13
-
-
Save Leonidas-from-XIV/143777bb5510dfe0f394 to your computer and use it in GitHub Desktop.
switch is not an expression? what?
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
enum Either<T, V> { | |
case Left(T) | |
case Right(V) | |
} | |
var lint: Either<Int, Any> = Either.Left(42) | |
var rstring: Either<Any, String> = Either.Right("at you") | |
switch rstring { | |
case .Right(let x): print("right", x) | |
case .Left: print("not right") | |
} | |
/* | |
* <stdin>:15:37: error: expected expression in list of expressions | |
* print("is this not an expression?", switch lint { | |
* ^ | |
* <stdin>:15:37: error: expected ',' separator | |
* print("is this not an expression?", switch lint { | |
* ^ | |
*/ | |
print("is this not an expression?", switch lint { | |
case .Left: "left" | |
case .Right: "right" | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment