Ifvwm
09/27/2019, 1:48 AMjw
09/27/2019, 1:53 AMreturn ::fIfvwm
09/27/2019, 2:30 AMjw
09/27/2019, 2:31 AMjw
09/27/2019, 2:32 AMIfvwm
09/27/2019, 2:40 AMstreetsofboston
09/27/2019, 2:52 AMf would be infinitely recursive:
(Int)->((Int)->((Int)->((Int)->... ...))))))))Ifvwm
09/27/2019, 2:59 AMjw
09/27/2019, 3:02 AMstreetsofboston
09/27/2019, 3:22 AMreturn ::f, unless f returns a plain Any itself,...streetsofboston
09/27/2019, 3:23 AMjw
09/27/2019, 3:24 AMIfvwm
09/27/2019, 3:26 AMfun test(x:String):(String)->(String)->Any{
println(x)
return ::test
}
test(“1”)(“2”)(“3”)streetsofboston
09/27/2019, 3:29 AM::test has the type (String)->((String)->(String)->Any).
Can that be coerced/cast to (String)->(String)->Any?
If so, then (String)->((String)->(String)->Any) is a sub-type of (String)->(String)->Any...Ifvwm
09/27/2019, 3:33 AMIfvwm
09/27/2019, 3:35 AMstreetsofboston
09/27/2019, 3:35 AM(String)->((String)->(String)->Any) safely assignable to a (String)->(String)->Any...streetsofboston
09/27/2019, 3:37 AMa -> a -> a -> b is a -> a -> b?Ifvwm
09/27/2019, 3:38 AMstreetsofboston
09/27/2019, 3:39 AMIfvwm
09/27/2019, 3:40 AMIfvwm
09/27/2019, 3:40 AMIfvwm
09/27/2019, 3:44 AMstreetsofboston
09/27/2019, 3:44 AMA with a concrete type Int. If A -> A is A, shouldn't Int -> Int be Int (after constructing it with an Int)?Ifvwm
09/27/2019, 3:46 AMIfvwm
09/27/2019, 3:47 AMstreetsofboston
09/27/2019, 3:49 AM(A)->A is ambiguous with any other lambda that looks like (A)->.... ....streetsofboston
09/27/2019, 3:49 AMIfvwm
09/27/2019, 3:51 AMstreetsofboston
09/27/2019, 3:53 AM(Z)->(Z)->(Z)->(Z)->(Z) 💤Ifvwm
09/27/2019, 3:53 AMBig Chungus
09/27/2019, 4:54 AMlateinit var f: (String) -> ((String) -> Any)
f = {
print(it)
f
}
f("1")("2")("3")molikuner
09/27/2019, 7:06 AMobject test {
operator fun invoke(i: Int) = also {
println(i)
}
}
fun main() {
test(0)(1)(2)(3)(4)
}