bod
06/26/2021, 9:22 AMfun <E> MutableCollection<E>.set(elements: Collection<E>) {
clear()
addAll(elements)
}
fun <E> MutableCollection<E>.set(vararg elements: E) = set(elements.asList())
bod
06/26/2021, 9:33 AMfun <K, V> MutableMap<K, V>.set(from: Map<K, V>) {
clear()
putAll(from)
}
fun <K, V> MutableMap<K, V>.set(vararg pairs: Pair<K, V>) {
clear()
putAll(pairs)
}
Dominaezzz
06/26/2021, 9:43 AMset
is confusing name to me. Since it's used for other stuff. Like setting an element in a list or map.bod
06/26/2021, 9:55 AMreset
then? replaceAll
would make sense, but that already exists on Map, with a different meaningephemient
06/26/2021, 7:12 PMvar Collection<E>
?ephemient
06/26/2021, 7:13 PMbod
06/27/2021, 12:09 PMresourceConfigurations
and manifestPlaceholders
bod
06/27/2021, 12:10 PMreplaceBy
or replaceAllBy
would be a good name)ephemient
06/27/2021, 6:23 PMset
would match the Provider.set
, but can be confused with MutableList.set(index, elem)
, replace
is also about items…andries.fc
09/17/2021, 10:35 AMoperator fun MutableSet<T>.assign(another:Collection<T>) {
clear()
addAll(another)
}
To be used as such:
val set = mutableSetOf(1, 2, 3)
set = setOf(12,13,16)
ephemient
09/18/2021, 8:17 PMvar _: MutableCollection<*>
- operator overloading isn't the right answer here, IMOephemient
09/18/2021, 8:25 PMfun <T> MutableCollection<T>.setAllValues(values: Iterable<T>)
fun <T> MutableCollection<T>.setValues(vararg values: T)
Dominaezzz
09/18/2021, 8:33 PM