From 1cd8f74c3c5d79761f9be0bd6a306ecb8363e37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lamarque?= Date: Mon, 24 Jul 2023 10:38:05 +0200 Subject: [PATCH] docs(#137): improve documentation of NotEmptySet.toSet function --- .../kotlin/kotools/types/collection/NotEmptySet.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/kotools/types/collection/NotEmptySet.kt b/src/commonMain/kotlin/kotools/types/collection/NotEmptySet.kt index 2d787e144..99a875480 100644 --- a/src/commonMain/kotlin/kotools/types/collection/NotEmptySet.kt +++ b/src/commonMain/kotlin/kotools/types/collection/NotEmptySet.kt @@ -81,7 +81,18 @@ public value class NotEmptySet private constructor( ?: setOf(head) ) - /** Returns all elements of this set as a [Set] of type [E]. */ + /** + * Returns all elements of this set as a [Set] of type [E]. + * + * ```kotlin + * import kotools.types.collection.NotEmptySet + * import kotools.types.collection.notEmptySetOf + * + * val notEmptySet: NotEmptySet = notEmptySetOf(1, 2, 3, 1) + * val set: Set = notEmptySet.toSet() + * println(set) // [1, 2, 3] + * ``` + */ public fun toSet(): Set { val elements: Set = setOf(head) return tail?.let { elements + it.toSet() } ?: elements