Add sample for setOf method

Ilya Gorbunov: Improve sample to illustrate stable iteration order and set equality.
This commit is contained in:
Swapnil Sankla
2018-01-14 20:53:02 +05:30
committed by Ilya Gorbunov
parent c5aed06110
commit b93e385181
2 changed files with 14 additions and 0 deletions
@@ -31,6 +31,7 @@ public fun <T> emptySet(): Set<T> = EmptySet
* Returns a new read-only set with the given elements.
* Elements of the set are iterated in the order they were specified.
* The returned set is serializable (JVM).
* @sample samples.collections.Collections.Sets.readOnlySet
*/
public fun <T> setOf(vararg elements: T): Set<T> = if (elements.size > 0) elements.toSet() else emptySet()