Bernhard
11/24/2020, 2:32 PMnfrankel
11/24/2020, 2:37 PMBernhard
11/24/2020, 2:37 PMBernhard
11/24/2020, 2:38 PMBernhard
11/24/2020, 2:38 PMBernhard
11/24/2020, 2:40 PMval x: CommonRun = obj1.run.apply("hi")
val y: CommonRun = obj2.run.apply(3, URI("<https://google.com>"))
Bernhard
11/24/2020, 2:40 PMBernhard
11/24/2020, 2:42 PMval x = CommonRun { obj1.run(it, "hi") }
but that’s a bit clunkyNir
11/24/2020, 2:44 PMnfrankel
11/24/2020, 2:45 PMAny
and you need to cast in subclasses
🤷♂️nfrankel
11/24/2020, 2:45 PMkralli
11/24/2020, 2:50 PMfun Common.run(value: Int): CommonRun = TODO()
Bernhard
11/24/2020, 2:54 PMkralli
11/24/2020, 2:57 PMNir
11/24/2020, 3:06 PMNir
11/24/2020, 3:07 PMNir
11/24/2020, 3:08 PMNir
11/24/2020, 3:11 PMfun<T, R> apply(fun: (T, Common) -> R, t: T) = { fun(t, it) }
fun<T, R> apply(fun: (Common, T) -> R, t: T) = { fun(it, t) }
fun<T, U, R> apply(fun: (Common, T, U) -> R, t: T, u: U) = { fun(it, t, u) }
fun<T, U, R> apply(fun: (T, Common, U) -> R, t: T, u: U) = { fun(t, it, u) }
fun<T, U, R> apply(fun: (T, U, Common) -> R, t: T, u: U) = { fun(t, u, it) }
...
Nir
11/24/2020, 3:11 PMNir
11/24/2020, 3:14 PM