thanksforallthefish
01/22/2019, 1:24 PMfun asString(): (Any) -> String = Any::toString
I can call it in 2 ways
- asString()(anObject)
- asString().invoke(anObject)
I believe the first way would be more idiomatic, but coming from java I still prefer the second (()()
looks too weird to me). For the sake of who will come after me, which version would you suggesting to use?marstran
01/22/2019, 1:33 PMval asString = Any::toString
. Then you can call it with asString(anObject)
.thanksforallthefish
01/22/2019, 1:50 PMthanksforallthefish
01/22/2019, 1:53 PMfun <A, B, C> ((A) -> B).then(then: (B) -> C): (A) -> C = { input -> then(this(input)) }
at call site is either:
- a.then(b).invoke(input)
- a.then(b)(input)
thanksforallthefish
01/22/2019, 1:55 PMa
and b
are something like val a = Any::toString
marstran
01/22/2019, 2:02 PMval
.
But anyway, I think a.then(b)(input)
looks better.bdawg.io
01/23/2019, 4:12 PMinvoke(...)
over this(...)
. There are other times where I've been restricted by Kotlin semantics (ie, b[c]?.doSomethingExisting() ?: b.set(c, default())
since ... ?: (b[c] = default())
is not allowed)