Hacker News new | past | comments | ask | show | jobs | submit login

I agree the syntax is sensible. I quite like it in Swift:

    protocol Numeric {
        func +(lhs: Self, rhs: Self) -> Self
    }

    func<T: Numeric>(a: T, b: T) -> T {
        return a + b
    }



Correction: Function name.

    func add<T: Numeric>(a: T, b: T) -> T {
        return a + b
    }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: