Generics and the Art of Inference Part 3 of 3

In the pre-generics days of Obj-C the only way to pass around things of unknown type was with an id type, but with Swift Generics/Protocols we can do things like Promises statically and safely with an associateType. Although large scale projects has been built in several Swift libraries already, we’ll look at how a barebones […]

Generics and the Art of Inference Part 2 of 3

Our example this round will be constructing/deconstructing a struct to and from a Dictionary.

Here is the basic definition of the struct we would like to encode/decode. We can define a protocol for this as simply:

Now we can extend our type to implement these, but before we do that let’s extend some […]

Generics and the Art of Inference Part 1 of 3

The power of inference in Swift generics is something I find most people underestimate and underuse. Personally generics and inference has saved me from writing tons of boilerplate and duplicated code. In any case there is a ton I’d like to share about this topic, but to begin here are a couple common cases where […]

Trying to Build a Better Hashable

The standard example: You have a type that is uniquely identifiable by an id property and want to be able to use contains on a collection of this type, while not worrying so much about having duplicates. For a single struct, we can conform to Hashable and implement a == case to handle the object. […]

Swift Gist Favorites of 2015

Taking a look back recently, I realized a lot of my Swift sharing has been in the form of gists and less in the form of blog. As thus, here is a breakdown of my top three Swift gists since 2.0 came out. 3 – Optional Array Accessor This is an array accessor that returns […]

Cast-Free Arithmetic

Updates: 10/13/2015 I recently gave a presentation on this topic @Realm, available in video format here. Cast-Free Arithmetic Part 1: Two months ago when WWDC week was happening and while many attendees were going to lectures, mingling at parties, and networking, I was resolved to take a deep dive into Swift 2.0 as quickly as […]

Recreating Defer Syntax in Swift 1.2

So, a few days ago, I had the bright idea that trying to recreate some of the shiny new Swift 2.0 features in Swift 1.2 might amount to a fun challenge. I first thought about recreating guard syntax, but quickly got stuck at finding a way of calling return in the scope of a function […]

Swift 2.0 Type Introspection

I’ve been at WWDC this week and it has been a whirlwind. I am feeling quite overwhelmed, overloaded, and oversaturated with newness, but to that effect I have something small to share about introspection in Swift 2.0. Pre Swift 2 you may recall some talk of a mirrorType mentioned both here in this video and in […]

First Post

  Hi All, This will be a blog to share my experience in studying Swift. I look forward to sharing the functional paradigms I have learned, the not so functional paradigms, and my experiences at WWDC.