Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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")

This is madness. Someone contact the Type Safe police...

erica commented Jun 7, 2016

@jckarter

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