jeudi 25 août 2016

Sweet Swift tricks

The more you look into the language, the more you realize that Swift is very well thought.

This ongoing article will give away some cool tricks of the language

Underscore characters in integers or floats


This is the kind of feature that makes you wonder why it hasn't been introduced in programming languages until these glorious Swift days. In Swift, reading large numbers isn't a struggle anymore.

let veryLargeInt = 1_000_000_000

You may place underscores anywhere you want in order for the number to make sense. Another example is credit card number

let uglyCreditCardNumber = 1234567890123456
let beautifulCreditCardNumber = 1234_5678_9012_3456

Aucun commentaire:

Enregistrer un commentaire