poohbar
01/02/2018, 7:28 PMval f1 = { it.length == 3} // T.() -> Boolean
val f2 = { length == 3} . // (T) -> Boolean
this does not look the same to meAndreas Sinz
01/02/2018, 7:43 PMkevinmost
01/02/2018, 7:55 PM(T) -> Boolean
and T.() -> Boolean
are both "a function that needs one param, a T
, as an input, and outputs a `Boolean`". It seems very reasonable that they'd both be treated the same way outside of the lambda's scope itselfpoohbar
01/02/2018, 7:56 PMxenoterracide
01/02/2018, 11:55 PMgildor
01/03/2018, 12:52 AMxenoterracide
01/03/2018, 4:38 AMkevinmost
01/03/2018, 4:39 AMxenoterracide
01/03/2018, 4:42 AMgildor
01/03/2018, 4:48 AMkevinmost
01/03/2018, 4:50 AMlength
can come from the implicit receiver type. Though without any type info stored here, the compiler can't really infer that, I believe. I think you'd have to do something like:
val f2: (T) -> Boolean = { length == 3 }
gildor
01/03/2018, 4:50 AMval f1: String.() -> Boolean = { length == 3 }
val f2: (String) -> Boolean = { it.length == 3 }
this