Swift, Labels, Default Parameters, oh my!

The other day I was working on Jazz and got to fully appreciate the convenience of default parameters in Swift. Default parameters combined with labels gives a simple and flexible method signature. This is in stark contrast to some other method signatures in other development environments. methods in these environments can have an upwards of 10 parameters, all with arbitrary names. Let’s take a look at an example of such methods:

»

Numbers and Swift

2 + 2 = 4. Aren’t numbers grand? They are the basic building blocks for all data we work with and Swift is no exception. Speaking (or typing) of numbers, I was working on SwiftLog the other day and came across a NSFileManager call that returned a NSNumber in Objective-C and a UInt64 in Swift. The different types inspired me to write this article. Objective-C only has NSNumber for a number object, while Swift has a whole list:

»