| prefix operator * {} | |
| /// Force-cast an Any to the type demanded by static context. | |
| prefix func *<T>(x: Any) -> T { | |
| return x as! T | |
| } | |
| var x: Any = 2 | |
| 1 + *x | |
| x = "world" | |
| "hello " + *x | |
| infix operator => {} | |
| /// Dynamically dispatch a method on Any. | |
| func =><T, U, V>(myself: Any, method: T -> U -> V) -> U -> V { | |
| return method(myself as! T) | |
| } | |
| (x=>String.hasPrefix)("wor") |
mishagray
commented
May 27, 2016
erica
commented
Jun 7, 2016
func =><T, U, V>(myself: Any, method: (T) -> (U) -> V) -> U -> V
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is madness. Someone contact the Type Safe police...