Apple released Swift officially as an alternative language for development, apart from Objective-C. It looks and reads like an easy-to-use scripting-like language. It is a modern language, and has the features of most modern languages such as Python, Ruby, Lua and Scala. Swift removes the need for semicolons and uses the standard double slash for comments, amongst other things, as shown here:
//This is a comment
The println
function is used for printing data. Swift also has a more evolved println
function that allows for formatted printing. The value of a variable can be inserted into a string by enclosing the variable name in brackets preceded by a slash: \(varname)
. This format has to be enclosed in double quotes to make it work.
println("Hello World") println("This is fine too"); var ver = 6 println("Hello from Xcode \(ver)")