I'm not too fond of the if let
syntax with optionals and I'm trying to see if I can get pattern matching to work instead. I'm trying the following code in a playground, but not seeing any output on the println
statements. What am I doing wrong?
let one:Int? = 1
switch one {
case .Some(let numeral):
println("Caught a \(numeral)")
default:
println("Nothing to catch")
}
A little bit out of context, but: Playground doesn't print the println()
statements in the right column.
You can write again the variable that you want to read:
...
case .Some(let numeral):
println("Caught a \(numeral)")
numeral
...
In this case you'll see {Some 2}
.
Or you can open the Assistant Editor (View -> Assistant Editor -> Show Assistant Editor) and read the Console output
to read the println()
evaluated.
EDIT after Xcode 6 beta-5
With Xcode 6 beta-5, you can finally println()
, you'll see the text in the right column.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With