Is something like this possible in kotlin? <https:...
# announcements
j
Is something like this possible in kotlin? https://pl.kotl.in/Byi2Xz5q7
g
Just add param name: { it -> it?.length ?: -1 }
Or maybe I don’t understand your case
j
I just wanted to know if I can write it in some way without the
it ->
part.
if it's not inside a map I can do it
g
You cannot, because type inference doesn’t support such case
👍 1
m
This could be something that is supported in the new type inference engine, but I'm not sure.
j
that would be really nice. You know where I can follow on the type inference engine development?
m
I heard about it in Svetlana Isakova's talk on KotlinConf.
👍 1
I can't find it on youtube yet, but it should be up soon I'd guess.
g
You can use som DSL instead for such cases to avoid this problem, but hard to recommend particular syntax without context
j
I have created a function that can take a mapping of
Map<Any?, (String) -> Any?)
. So I just wanted to shorten wherever it was used. Like from this:
line -> line?.toIntOrNull()
into
it?.toIntOrNull
😉
n
you could change this to take
String.() -> Any?
then you can use this.. or ignore it and have no parameters, your choice.. might look cleaner
👍 1
d
Actually yes, that works in New Inference
👍 3