Swift Programming Language

4 thoughts
last posted June 8, 2014, 6:19 p.m.
1
get stream as: markdown or atom
0

The path xcrun resolves swift to:

/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
0

I find this snippet of Swift very clean. Looks like type pattern matching?

enum ServerResponse {
    case Result(String, String)
    case Error(String)
}

let success = ServerResponse.Result("6:00 am", "8:09 pm")
let failure = ServerResponse.Error("Out of cheese.")

switch success {
case let .Result(sunrise, sunset):
    let serverResponse = "Sunrise is at \(sunrise) and sunset is at \(sunset)."
case let .Error(error):
    let serverResponse = "Failure...  \(error)"
}
0

Use the Swift REPL:

$ sudo xcode-select -switch /Applications/Xcode6-Beta.app/Contents/Developer
$ xcrun swift