We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
unique
1 parent 2808213 commit a05bbf6Copy full SHA for a05bbf6
src/core/collections.scala
@@ -120,6 +120,7 @@ extension [ElemType](seq: Seq[ElemType])
120
inline def prim: Optional[ElemType] = if seq.isEmpty then Unset else seq.head
121
inline def sec: Optional[ElemType] = if seq.length < 2 then Unset else seq(1)
122
inline def ter: Optional[ElemType] = if seq.length < 3 then Unset else seq(2)
123
+ inline def unique: Optional[ElemType] = if seq.length == 1 then seq.head else Unset
124
125
def runsBy(lambda: ElemType => Any): List[List[ElemType]] =
126
@tailrec
0 commit comments