Operator overloading and custom operators are a great way to make your Swift code more readable. Here are a couple of nice tutorials that explore operator overloading, and creating custom operators in-depth from Nick Hanan.
In the first tutorial Nick does a nice job of explaining operator overloading, and why you’d like to do and shows how to set up a custom minus operator working with dates, and how to overload the == operator to compare two objects of the same type.
In the second tutorial Nick explains how to create completely custom operators, and creates a custom postfix percentage operator, and a custom infix power operator.
You can find the tutorials on operator overloading and custom operators on the Coding Explorer blog:
Tutorial 1 – Operator Overloading
Tutorial 2 – Custom Operators.
Some nice tutorials for those unfamiliar with operator overloading.
You may also be interested in: Euler – A Swift library providing over 40 custom math operators.
Original article: Tutorials: Swift Operator Overloading And Custom Operators Explained In-Depth
©2014 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.