Re:Functor and Monad in Swift
by IsTom on Friday January 02, 2015 @06:40AM
(#8826422)
Is there return type polymorphism in Swift? Without it monad-generic operations are limited.
[ Parent
| on HN ]
Re:Functor and Monad in Swift
by josephlord on Friday January 02, 2015 @12:00PM
(#8827470)
Yes.
func f()->Bool {
return true
}
func f()->Int {
return 5
}
let i:Int = f()
let b:Bool = f()
println(i) // Prints 5
println(b) // Prints true
// This would be compile error as ambiguous
//println(f())