Skip to content

Instantly share code, notes, and snippets.

@ArtSabintsev
Last active October 27, 2016 04:12
Show Gist options
  • Save ArtSabintsev/fb57027265b42fac9169c0ee72937239 to your computer and use it in GitHub Desktop.
Save ArtSabintsev/fb57027265b42fac9169c0ee72937239 to your computer and use it in GitHub Desktop.
Overloading Generic and Non-Generic Functions
import Foundation
typealias T = Int
struct S {
public static func f<T>(a: T, b: Int) {
print(a, b)
f(a: a, b: b) // Infinitely calls the f<t>{} method (e.g., creates infinite loop)
}
private static func f(a: T, b: Int) {
print(a, b) // This is never reached even though it's called by f<T>{}
}
}
S.f(a: 1, b: 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment