Mobile Applications Press Releases

Swift 4, review the new

Mobile Application Press Release

Apple announced (link is external) release of Swift 4.0 on the official blog of Swift language. Great news is that new Swift doesn’t contain so many epic changes like Swift 3.0 did, and most changes have full backwards compatibility. So you can just relax and kick back, let’s take a quick look at all innovations.


RangeExpression protocol was added to simplify creation of methods that use ranges. Also the standard library can detect start and end indices of ranges from now, so you don’t need to explicitly specify them [SE-0172](link is external) Make an Inquiry about this news:

let s = "Hello, World!"

let i = s.index(of: ",")!

// half-open right-handed range

let greeting = s[..<i]

// closed right-handed range

let withComma = s[...i]

// left-handed range (no need for half-open variant)

let location = s[i...]]

A great way to use one-sided ranges is pattern matching:

switch year {

case 2001...: print("Next millennium is here")

default: print("Keep calm and wait!")



Multi-line String Literals

The multi-line string literals come in handy when you need to build long formatted texts for UI or XML or JSON messages. In Swift 4, you can do this using three double-quotes (""") [SE-0168](link is external) Make an Inquiry about this news:

    let longAndFormatedString = """

“Talk is cheap.