String { return "Integer" } func alias(a:T...">

General and early binding in Swift 1.2

func f<T>(a:T)->String { return "Generic" }
func f(a:Int)->String { return "Integer" }
func alias<T>(a:T)->String { return f(a) }

f(1) // "Integer"
f("string") // "Generic"

alias(1) // "Generic" (shouldn't be "Integer" ?)
alias("string") // "Generic"

      

I understand that some form of early (static) binding is going on, but I don't understand why. Is this by design or a bug? if by design then alias(a) =/= f(a)

, but the definition reads exactly alias(a) = f(a)

!

+3


source to share





All Articles