Whats New in Swift 3.1

With Xcode 8.3 and iOS 10.3 Swift 3.1 was released. Swift 3.1 is a minor release that contains improvements and refinements to the Standard Library. Swift 3.1 is source-compatible with Swift 3.0, so the new features enhancements won’t break your code. You can also check our previous tutorial: “Whats new in Swift 3”  here.

Language Updates in Swift 3.1

It is a minor language release. It is source compatible with Swift 3.0. It contains the following language changes and updates.

New Sequence protocol members:

Let’s learn about them with some example:

Prefix :

The result will be [22, 32, 25, 8, 6]. It doesn’t contain the elements which are great than 40 but come after 45.

Drop :


The result will be something like this [45, 33, 28, 38, 50] finally. Dropped elements 22 to 6. After 45 elements all are kept.

Failable Numeric Conversion Initializers

Swift 3.1 implements failable initializers for all numeric types. This comes in handy  when dealing with loosely typed data conversions from external sources in a safe and recoverable manner

If marksObtained is a fractional value, it will fail. If it can be represented exactly with an Int, it will succeed.



Availability by Swift Version

You can check specific Swift version with the #if swift(>= N) static construct like this:


But Swift 3.1 also extends the @available attribute to support specifying Swift version numbers in addition to its existing platform versions



You can also read more from Whats new in Swift 3.1 Apple’s Swift Blog here .



Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.