fellshard
06/24/2016, 5:14 PMjkbbwr
06/24/2016, 5:16 PMfellshard
06/24/2016, 5:21 PMjkbbwr
06/24/2016, 5:27 PMyuriy.yarosh
06/26/2016, 7:10 PMclass Testo(
val value: Int
) {
companion object parse {
operator fun invoke(value: Int): Testo {
return Testo(value + 1);
}
}
}
fun main(args: Array<String>) {
println(Testo(1).value)
}
So it’ll obviously print 1 and call primary constructor instead of the invoke() operator.
I think this one should be considered as a small issue.
Assigning invoke() operator for the companion object allows to build very neat factory methods.
Just wondering: should I create an YouTrack Kotlin issue for this matter ?voddan
06/26/2016, 7:57 PMvoddan
06/26/2016, 7:58 PMRuckus
06/26/2016, 8:00 PMRuckus
06/26/2016, 8:01 PMyuriy.yarosh
06/27/2016, 5:17 AMgroostav
06/28/2016, 7:25 AMin
such that one takes a custom equality comparator?groostav
06/28/2016, 7:25 AMinfix fun <T> Collection<T>.by(equalityComparator: (T, T) -> Boolean) : Collection<T> {
groostav
06/28/2016, 7:25 AMgroostav
06/28/2016, 7:25 AMsomething !in someCollection by YourType::theMethodToCompareUsing
groostav
06/28/2016, 7:30 AMby
kirillrakhman
06/28/2016, 7:44 AMlist.any {}
. Not everything needs to be an operatorgroostav
06/28/2016, 7:49 AMgroostav
06/28/2016, 7:51 AMgroostav
06/28/2016, 7:52 AMsomeList.removeAll { it !in anotherList by MyType::isSpecialEquals }
someList.removeAll { candidate -> anotherList.any { it.isSpecialEquals(candidate) } }
voddan
06/28/2016, 7:54 AMvoddan
06/28/2016, 7:55 AMgroostav
06/28/2016, 7:55 AMwhich requires the creation of a weird object as the return value fromby
voddan
06/28/2016, 7:56 AMvoddan
06/28/2016, 7:57 AMgroostav
06/28/2016, 7:57 AMby
method might make it into standard.kt
or Collections.kt
or what-have-yougroostav
06/28/2016, 7:58 AMgroostav
06/28/2016, 7:58 AMvoddan
06/28/2016, 8:01 AMvoddan
06/28/2016, 8:02 AMyole
06/28/2016, 8:22 AM