5: Println in Swift

In programming its very common to display output on screen. Swift provides a very handy built-in function called println().

println("Hello from Swift")

You can print different variables with println function.

var myName = "Khan"
println(myName)

You can also print your string with variable at same time.¬†To achieve this task you need two things one is back-slash ‘\’ and second is small brackets ‘( )’. This technique is called string interpolation.

var myName = "Khan"
var country = "Sweden"
var myPostCode = 12345

println("My Name is \(myName), i live in \(country) and my postcode is \(myPostCode)")

 

 

Download file from GitHub