artem_zin08/04/2016, 1:46 PM
on map, but can’t
? Basically I have immutable map and I need to remove item from it and get new immutable map as result.
kittinunf08/04/2016, 1:47 PM
thomasnield08/04/2016, 1:52 PM
ilya.gorbunov08/04/2016, 2:48 PM
operation? Should it take a key as an argument or a key-value pair like
artem_zin08/04/2016, 2:50 PM
ilya.gorbunov08/04/2016, 2:52 PM
with a code example?
artem_zin08/04/2016, 2:57 PM
Valid variants: *
var map = mapOf(“s” to 1) map -= “s"
Looks like there is no much sense in giving api to remove by key value pair, only key matters for
ilya.gorbunov08/04/2016, 2:59 PM
is not symmetrical with
, i.e. takes a key, whereas
takes a pair, so we decided not to provide them. We may reconsider that decision.
artem_zin08/04/2016, 3:02 PM
because it returns removed value and not the new map. I see two ways at the moment:
(which is slow obviously) or create new mutable map with content of previous, remove item from it, then make it readonly.
ilya.gorbunov08/04/2016, 3:04 PM
you can do just
, but for read-only maps there is no easy way for now.
map.keys -= key
jw08/04/2016, 3:05 PM
jw08/04/2016, 3:06 PM
might be faster than your second suggestion since the entries can be re-used instead of copied
thomasnield08/04/2016, 3:07 PM
ilya.gorbunov08/04/2016, 3:08 PM
member function which returns new
jw08/04/2016, 3:09 PM
artem_zin08/04/2016, 3:11 PM
thomasnield08/04/2016, 3:16 PM
kind of does that already. As long as
has some form of
equivalent I'll be cool with that.
thomasnield08/04/2016, 3:17 PM
ilya.gorbunov08/04/2016, 3:17 PM
returns read-only map of read-only lists. Is read-only sufficient, or do you need immutability?
thomasnield08/04/2016, 3:19 PM
voddan08/04/2016, 3:21 PM
I don't need immutability, but I like it. I understand it performs betterusually it does not
thomasnield08/04/2016, 3:24 PM
boasted some pretty sizable performance over
ilya.gorbunov08/04/2016, 3:31 PM
artem_zin08/04/2016, 3:31 PM
deserve to live in stdlib?
ilya.gorbunov08/04/2016, 3:32 PM
artem_zin08/04/2016, 3:34 PM
ilya.gorbunov08/04/2016, 3:36 PM
rocketraman08/04/2016, 7:25 PM
function. Should one exist in stdlib?
fun <T> List<T>.replace(index: Int, new: T): List<T>