jw
08/04/2016, 7:29 PMMutableList
has set
for thatrocketraman
08/04/2016, 7:30 PMList
, returning a new read-only List
jw
08/04/2016, 7:30 PMjw
08/04/2016, 7:32 PMinline fun <T> List<T> transform(f: MutableList<T>.() -> Unit): List<T>
so that you do list.transform { set(0, foo) }
because you could also chain multiple mutable operators inside that lambdajw
08/04/2016, 7:32 PMmutate
rocketraman
08/04/2016, 7:33 PMjw
08/04/2016, 7:34 PMrocketraman
08/04/2016, 7:35 PMrocketraman
08/04/2016, 7:41 PMset(index, get(index).let { it.copy(...) })
ilya.gorbunov
08/04/2016, 8:57 PMfun <T> ImmutableList<T>.mutate((MutableList<T>) -> Unit): ImmutableList<T>
for immutable list. Also its set
function has the signature as @rocketraman asking: fun set(index: Int, element: E): ImmutableList<E>
.
Not sure, we should have something like for read-only lists though.rocketraman
08/04/2016, 8:59 PMmutate
for read-only list as well?ilya.gorbunov
08/04/2016, 9:09 PMMutableList
instance passed to the lambda leaking somewhere outside.rocketraman
08/04/2016, 9:11 PMhastebrot
08/08/2016, 9:15 AMimmutable.js
has a Seq.cacheResult()
function (https://facebook.github.io/immutable-js/docs/#/Seq/cacheResult).
If you know a Seq will be used multiple times, it may be more efficient to first cache it in memory.
Use this method judiciously, as it must fully evaluate a Seq which can be a burden on memory and possibly performance.
hastebrot
08/08/2016, 9:16 AMmbickel
08/08/2016, 9:30 AMhastebrot
08/08/2016, 9:40 AMmbickel
08/08/2016, 9:42 AMhastebrot
08/08/2016, 9:57 AMhastebrot
08/08/2016, 9:58 AMhastebrot
08/08/2016, 10:01 AMiterator()
(i.e. it
) introduces mutability.dimsuz
08/08/2016, 12:03 PMartem_zin
08/08/2016, 12:53 PMlinkedMap.toList().indexOfFirst { condition }
dimsuz
08/08/2016, 12:54 PMuhe
08/08/2016, 1:00 PMuhe
08/08/2016, 1:03 PMlinkedMap.entries.indexOfFirst { condition }
should also workdimsuz
08/08/2016, 1:34 PMdimsuz
08/08/2016, 3:10 PMvar map: Map<K,V>? = null
class property
2. I do not (or can not) use delegates.lazy for whatever reason
Is there some idiomatic way to say:
if(map == null) { map = mutableMapOf() }
map.doSomething()
or is this the same as with java? I know I could use apply/let stuff here, but dunno if this is the wayvmironov
08/08/2016, 3:11 PMmap.orEmpty().doSomething()