what's an idiomatic way to get a list that has a s...
# announcements
j
what's an idiomatic way to get a list that has a single element prepended to an existing list. I've been doing:
listOf(listOf(newElement), existingList).flatten()
but that's a bit cumbersome. realized I can do
listOf(newElement).union(existingList)
, but that gives a
Set
instead of a
List
, which isn't always desired.
n
what about
listOf(newElement) + existingList
j
Ha that's probably it! I was looking for a named function and skipped right over
+