All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mchange.conveniences.collection.core.scala~ Maven / Gradle / Ivy

The newest version!
package com.mchange.conveniences.collection

import scala.collection.*

object NotUnique:
  case object Empty extends NotUnique
  case class Multiple( n : Int ) extends NotUnique
sealed trait NotUnique

extension[T] ( c : Seq[T] | Set[T] )
  def uniqueOr( notUnique : NotUnique => T ) : T =
    c.size match
      case 0 => notUnique( NotUnique.Empty )
      case 1 => c.head
      case n => notUnique( NotUnique.Multiple(n) )




© 2015 - 2024 Weber Informatics LLC | Privacy Policy