https://kotlinlang.org logo
Title
a

amanda.hinchman-dominguez

05/08/2019, 12:23 AM
I wanna say no but why allow this in a constructor parameter?
n

Nate

05/08/2019, 12:24 AM
a

amanda.hinchman-dominguez

05/08/2019, 12:24 AM
ah!!! you're the best. Thank you so much!
n

Nate

05/08/2019, 12:24 AM
Lol, np
a

amanda.hinchman-dominguez

05/08/2019, 12:25 AM
second reaction - lol that's crazy
I really didn't think this sort of thing is allowed and now I'm about to abuse the hell out of this 😈
i

ilya.gorbunov

05/08/2019, 12:38 AM
Btw,
compareBy
is a function taking a vararg of functions: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.comparisons/compare-by.html
a

amanda.hinchman-dominguez

05/08/2019, 12:40 AM
@Nate but can a
vararg
only be referenced within an
init
block?
@ilya.gorbunov Interesting, I'll have to see how that's implemented. this is definitely a rabbit hole worth diving into!
n

Nate

05/08/2019, 12:43 AM
you can declare it as
vararg val functions
to be able to use it elsewhere
a

amanda.hinchman-dominguez

05/08/2019, 12:45 AM
oh my, I was mixing up the order! thanks!
Also, I looked into the comparator functions.... I wish I could write something as elegant and beautiful. With more time I can!
p

Pere Casafont

05/08/2019, 6:05 AM
It is just syntactic sugar around Array<(String) -> String>