Another Approach To Phantom Types in Swift – Self Commenting Code

If you found yesterday’s post Phantom Types in Swift To Catch Errors At Compile Time of interest, you’ll want to read this post on Choosing the Best Expression.

The latter post does an analysis of the code example in the former, highlighting the choice of using a map expression versus if-let. The primary objective of the compare/contrast is to emphasize code that make it clear what the intention is, without the need to dig out reference documentation.

I’m a huge fan of well commented code, and even better when you code itself makes your intention clear.