Printing formatted strings in Swift

I'm just getting started with Swift, so I may be missing out on some awesome things yet and I do have some catching up to do on the language, but this is nice - especially compared to Objective-C.

If you need to print out the contents of a variable in Objectice-C you'd do:

NSString *string = @"Hello world";  
NSLog("string = %@", string)  

But in Swift, you can simply do:

let string = "Hello world" // Already better  
println("string = \(string)")  

So nice.


comments powered by Disqus