Dmitry Kandalov
02/10/2021, 11:27 PMList
but lowercase `sequence`:
List(size = 1) { "foo" }
sequence { yield("foo") }
Marc Knaup
02/10/2021, 11:39 PMDmitry Kandalov
02/10/2021, 11:57 PMpublic inline fun <T> List(...): List<T> = ...
public fun <T> sequence(...): Sequence<T> = ...
ephemient
02/11/2021, 2:27 AMJordan Stewart
02/11/2021, 9:21 AMkotlin/collections/Sequences.kt
contains the following though--
public inline fun <T> Sequence(crossinline iterator: () -> Iterator<T>): Sequence<T> = object : Sequence<T> {
override fun iterator(): Iterator<T> = iterator()
}
e.g. the implementation of fun sequence(..)
is just Sequence { iterator(block) }
, calling fun Sequence(..)
— this is the one which I’m most curious about!Jordan Stewart
02/11/2021, 9:32 AMinterface Sequence
into effectively fun interface Sequence
, but why guess when you can ask? 🙂)Dmitry Kandalov
02/12/2021, 10:36 AMList(n) { ... } is clearly a constructor or function invocationYes.
Runnable { ... } is clearly a lambdaNot unless you know that Runnable is a functional interface, so I wouldn’t say “clearly” 😉
sequence { ... } is clearly a function invocationYes. The question is why make it clearly a function and also have
fun Sequence(){...}
. It would be a more consistent coding style in stdlib to capitalise all functions if they have the same name as returning type.ephemient
02/12/2021, 5:32 PMephemient
02/12/2021, 5:33 PMbuildString { ... }
buildList { ... }
etc., but there was a community poll a little while back where people seemed to mostly prefer the non-build-prefixed names so...Marc Knaup
02/12/2021, 5:40 PM