Last active
October 27, 2016 04:12
-
-
Save ArtSabintsev/fb57027265b42fac9169c0ee72937239 to your computer and use it in GitHub Desktop.
Overloading Generic and Non-Generic Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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