Overloading function in Swift

Khoa Pham
Khoa Pham
Oct 22, 2016 · 1 min read

Function

Functions in Swift are distinguishable by

- parameter label
- parameter type
- return type

so that these are all valid, and works for `subscript` as well

When you specialize a generic type, like `Array<Int>`, you’re actually using a concrete type

Unfortunately, this does not work for NSObject subclass

> Method ‘get()’ with Objective-C selector ‘get’ conflicts with previous declaration with the same Objective-C selector

Generic function

We can overload generic functions as well

Fantageek

Simple apps that make sense

Khoa Pham

Written by

Khoa Pham

My apps https://onmyway133.github.io/

Fantageek

Fantageek

Simple apps that make sense

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade