Overloading function in Swift
Contents
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
1 |
struct A { |
When you specialize a generic type, like Array
, 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
1 |
class B: NSObject { |
Generic function
We can overload generic functions as well
1 |
func f |