-
-
Save jckarter/2762c4fe91d8eba4b1ce27060b4c601d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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") |
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...