package anyvals
- Alphabetic
- Public
- Protected
Type Members
- final class NonEmptyArray[T] extends AnyVal
A non-empty array: an ordered, mutable, non-empty collection of elements with
IndexedSeqperformance characteristics.A non-empty array: an ordered, mutable, non-empty collection of elements with
IndexedSeqperformance characteristics.The purpose of
NonEmptyArrayis to allow you to express in a type that anArrayis non-empty, thereby eliminating the need for (and potential exception from) a run-time check for non-emptiness. For a non-empty immutable sequence withIndexedSeqperformance, seeEvery.Constructing
NonEmptyArraysYou can construct a
NonEmptyArrayby passing one or more elements to theNonEmptyArray.applyfactory method:scala> NonEmptyArray(1, 2, 3) res0: org.scalactic.anyvals.NonEmptyArray[Int] = NonEmptyArray(1, 2, 3)
Working with
NonEmptyArraysNonEmptyArraydoes not extend Scala'sSeqorTraversabletraits because these require that implementations may be empty. For example, if you invoketailon aSeqthat contains just one element, you'll get an emptySeq:scala> Array(1).tail res6: Array[Int] = Array()
On the other hand, many useful methods exist on
Seqthat when invoked on a non-emptySeqare guaranteed to not result in an emptySeq. For convenience,NonEmptyArraydefines a method corresponding to every suchSeqmethod. Here are some examples:NonEmptyArray(1, 2, 3).map(_ + 1) // Result: NonEmptyArray(2, 3, 4) NonEmptyArray(1).map(_ + 1) // Result: NonEmptyArray(2) NonEmptyArray(1, 2, 3).containsSlice(NonEmptyArray(2, 3)) // Result: true NonEmptyArray(1, 2, 3).containsSlice(NonEmptyArray(3, 4)) // Result: false NonEmptyArray(-1, -2, 3, 4, 5).minBy(_.abs) // Result: -1
NonEmptyArraydoes not currently define any methods corresponding toSeqmethods that could result in an emptySeq. However, an implicit converison fromNonEmptyArraytoArrayis defined in theNonEmptyArraycompanion object that will be applied if you attempt to call one of the missing methods. As a result, you can invokefilteron anNonEmptyArray, even thoughfiltercould result in an empty sequence—but the result type will beArrayinstead ofNonEmptyArray:NonEmptyArray(1, 2, 3).filter(_ < 10) // Result: Array(1, 2, 3) NonEmptyArray(1, 2, 3).filter(_ > 10) // Result: Array()
You can use
NonEmptyArrays inforexpressions. The result will be anNonEmptyArrayunless you use a filter (anifclause). Because filters are desugared to invocations offilter, the result type will switch to aArrayat that point. Here are some examples:scala> import org.scalactic.anyvals._ import org.scalactic.anyvals._ scala> for (i <- NonEmptyArray(1, 2, 3)) yield i + 1 res0: org.scalactic.anyvals.NonEmptyArray[Int] = NonEmptyArray(2, 3, 4) scala> for (i <- NonEmptyArray(1, 2, 3) if i < 10) yield i + 1 res1: Array[Int] = Array(2, 3, 4) scala> for { | i <- NonEmptyArray(1, 2, 3) | j <- NonEmptyArray('a', 'b', 'c') | } yield (i, j) res3: org.scalactic.anyvals.NonEmptyArray[(Int, Char)] = NonEmptyArray((1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c)) scala> for { | i <- NonEmptyArray(1, 2, 3) if i < 10 | j <- NonEmptyArray('a', 'b', 'c') | } yield (i, j) res6: Array[(Int, Char)] = Array((1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c))- T
the type of elements contained in this
NonEmptyArray
- final class NonEmptyList[+T] extends AnyVal
A non-empty list: an ordered, immutable, non-empty collection of elements with
LinearSeqperformance characteristics.A non-empty list: an ordered, immutable, non-empty collection of elements with
LinearSeqperformance characteristics.The purpose of
NonEmptyListis to allow you to express in a type that aListis non-empty, thereby eliminating the need for (and potential exception from) a run-time check for non-emptiness. For a non-empty sequence withIndexedSeqperformance, seeEvery.Constructing
NonEmptyListsYou can construct a
NonEmptyListby passing one or more elements to theNonEmptyList.applyfactory method:scala> NonEmptyList(1, 2, 3) res0: org.scalactic.anyvals.NonEmptyList[Int] = NonEmptyList(1, 2, 3)
Alternatively you can cons elements onto the
Endsingleton object, similar to making aListstarting withNil:scala> 1 :: 2 :: 3 :: Nil res0: List[Int] = List(1, 2, 3) scala> 1 :: 2 :: 3 :: End res1: org.scalactic.NonEmptyList[Int] = NonEmptyList(1, 2, 3)
Note that although
Nilis aList[Nothing],Endis not aNonEmptyList[Nothing], because no emptyNonEmptyListexists. (A non-empty list is a series of connected links; if you have no links, you have no non-empty list.)scala> val nil: List[Nothing] = Nil nil: List[Nothing] = List() scala> val nada: NonEmptyList[Nothing] = End <console>:16: error: type mismatch; found : org.scalactic.anyvals.End.type required: org.scalactic.anyvals.NonEmptyList[Nothing] val nada: NonEmptyList[Nothing] = End ^Working with
NonEmptyListsNonEmptyListdoes not extend Scala'sSeqorTraversabletraits because these require that implementations may be empty. For example, if you invoketailon aSeqthat contains just one element, you'll get an emptySeq:scala> List(1).tail res6: List[Int] = List()
On the other hand, many useful methods exist on
Seqthat when invoked on a non-emptySeqare guaranteed to not result in an emptySeq. For convenience,NonEmptyListdefines a method corresponding to every suchSeqmethod. Here are some examples:NonEmptyList(1, 2, 3).map(_ + 1) // Result: NonEmptyList(2, 3, 4) NonEmptyList(1).map(_ + 1) // Result: NonEmptyList(2) NonEmptyList(1, 2, 3).containsSlice(NonEmptyList(2, 3)) // Result: true NonEmptyList(1, 2, 3).containsSlice(NonEmptyList(3, 4)) // Result: false NonEmptyList(-1, -2, 3, 4, 5).minBy(_.abs) // Result: -1
NonEmptyListdoes not currently define any methods corresponding toSeqmethods that could result in an emptySeq. However, an implicit converison fromNonEmptyListtoListis defined in theNonEmptyListcompanion object that will be applied if you attempt to call one of the missing methods. As a result, you can invokefilteron anNonEmptyList, even thoughfiltercould result in an empty sequence—but the result type will beListinstead ofNonEmptyList:NonEmptyList(1, 2, 3).filter(_ < 10) // Result: List(1, 2, 3) NonEmptyList(1, 2, 3).filter(_ > 10) // Result: List()
You can use
NonEmptyLists inforexpressions. The result will be anNonEmptyListunless you use a filter (anifclause). Because filters are desugared to invocations offilter, the result type will switch to aListat that point. Here are some examples:scala> import org.scalactic.anyvals._ import org.scalactic.anyvals._ scala> for (i <- NonEmptyList(1, 2, 3)) yield i + 1 res0: org.scalactic.anyvals.NonEmptyList[Int] = NonEmptyList(2, 3, 4) scala> for (i <- NonEmptyList(1, 2, 3) if i < 10) yield i + 1 res1: List[Int] = List(2, 3, 4) scala> for { | i <- NonEmptyList(1, 2, 3) | j <- NonEmptyList('a', 'b', 'c') | } yield (i, j) res3: org.scalactic.anyvals.NonEmptyList[(Int, Char)] = NonEmptyList((1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c)) scala> for { | i <- NonEmptyList(1, 2, 3) if i < 10 | j <- NonEmptyList('a', 'b', 'c') | } yield (i, j) res6: List[(Int, Char)] = List((1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c))- T
the type of elements contained in this
NonEmptyList
- final class NonEmptyMap[K, +V] extends AnyVal
A non-empty map: an ordered, immutable, non-empty collection of key-value tuples with
LinearSeqperformance characteristics.A non-empty map: an ordered, immutable, non-empty collection of key-value tuples with
LinearSeqperformance characteristics.The purpose of
NonEmptyMapis to allow you to express in a type that aMapis non-empty, thereby eliminating the need for (and potential exception from) a run-time check for non-emptiness. For a non-empty sequence withIndexedSeqperformance, seeEvery.Constructing
NonEmptyMapsYou can construct a
NonEmptyMapby passing one or more elements to theNonEmptyMap.applyfactory method:scala> NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three") res0: org.scalactic.anyvals.NonEmptyMap[Int, String] = NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three")
Working with
NonEmptyMapsNonEmptyMapdoes not extend Scala'sMaporTraversabletraits because these require that implementations may be empty. For example, if you invoketailon aSeqthat contains just one element, you'll get an emptySeq:scala> Map(1 -> "one").tail res6: Map[Int] = Map()
On the other hand, many useful methods exist on
Mapthat when invoked on a non-emptySeqare guaranteed to not result in an emptyMap. For convenience,NonEmptyMapdefines a method corresponding to every suchMapmethod. Here are an example:NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three").map(t => (t._1 + 1, t._2)) // Result: NonEmptyMap(2 -> "one", 3 -> "two", 4 -> "three")
NonEmptyMapdoes not currently define any methods corresponding toMapmethods that could result in an emptyMap. However, an implicit converison fromNonEmptyMaptoMapis defined in theNonEmptyMapcompanion object that will be applied if you attempt to call one of the missing methods. As a result, you can invokefilteron anNonEmptyMap, even thoughfiltercould result in an empty map—but the result type will beMapinstead ofNonEmptyMap:NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three").filter(_._1 < 10) // Result: Map(1 -> "one", 2 -> "two", 3 -> "three") NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three").filter(_._ 1> 10) // Result: Map()
You can use
NonEmptyMaps inforexpressions. The result will be anNonEmptyMapunless you use a filter (anifclause). Because filters are desugared to invocations offilter, the result type will switch to aMapat that point. Here are some examples:scala> import org.scalactic.anyvals._ import org.scalactic.anyvals._ scala> for ((i, j) <- NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three")) yield (i + 1, j) res0: org.scalactic.anyvals.NonEmptyMap[Int, String] = NonEmptyMap(2 -> "one", 3 -> "two", 4 -> "three") scala> for ((i, j) <- NonEmptyMap(1, 2, 3) if i < 10) yield (i + 1, j) res1: Map[Int, String] = Map(2 -> "one", 3 -> "two", 4 -> "three")
- K
the type of key contained in this
NonEmptyMap- V
the type of value contained in this
NonEmptyMap
- final class NonEmptySet[T] extends AnyVal
A non-empty Set: an ordered, immutable, non-empty collection of elements with
LinearSeqperformance characteristics.A non-empty Set: an ordered, immutable, non-empty collection of elements with
LinearSeqperformance characteristics.The purpose of
NonEmptySetis to allow you to express in a type that aSetis non-empty, thereby eliminating the need for (and potential exception from) a run-time check for non-emptiness. For a non-empty sequence withIndexedSeqperformance, seeEvery.Constructing
NonEmptySetsYou can construct a
NonEmptySetby passing one or more elements to theNonEmptySet.applyfactory method:scala> NonEmptySet(1, 2, 3) res0: org.scalactic.anyvals.NonEmptySet[Int] = NonEmptySet(1, 2, 3)
Alternatively you can cons elements onto the
Endsingleton object, similar to making aSetstarting withNil:scala> 1 :: 2 :: 3 :: Nil res0: Set[Int] = Set(1, 2, 3) scala> 1 :: 2 :: 3 :: End res1: org.scalactic.NonEmptySet[Int] = NonEmptySet(1, 2, 3)
Note that although
Nilis aSet[Nothing],Endis not aNonEmptySet[Nothing], because no emptyNonEmptySetexists. (A non-empty Set is a series of connected links; if you have no links, you have no non-empty Set.)scala> val nil: Set[Nothing] = Nil nil: Set[Nothing] = Set() scala> val nada: NonEmptySet[Nothing] = End <console>:16: error: type mismatch; found : org.scalactic.anyvals.End.type required: org.scalactic.anyvals.NonEmptySet[Nothing] val nada: NonEmptySet[Nothing] = End ^Working with
NonEmptySetsNonEmptySetdoes not extend Scala'sSeqorTraversabletraits because these require that implementations may be empty. For example, if you invoketailon aSeqthat contains just one element, you'll get an emptySeq:scala> Set(1).tail res6: Set[Int] = Set()
On the other hand, many useful methods exist on
Seqthat when invoked on a non-emptySeqare guaranteed to not result in an emptySeq. For convenience,NonEmptySetdefines a method corresponding to every suchSeqmethod. Here are some examples:NonEmptySet(1, 2, 3).map(_ + 1) // Result: NonEmptySet(2, 3, 4) NonEmptySet(1).map(_ + 1) // Result: NonEmptySet(2) NonEmptySet(1, 2, 3).containsSlice(NonEmptySet(2, 3)) // Result: true NonEmptySet(1, 2, 3).containsSlice(NonEmptySet(3, 4)) // Result: false NonEmptySet(-1, -2, 3, 4, 5).minBy(_.abs) // Result: -1
NonEmptySetdoes not currently define any methods corresponding toSeqmethods that could result in an emptySeq. However, an implicit converison fromNonEmptySettoSetis defined in theNonEmptySetcompanion object that will be applied if you attempt to call one of the missing methods. As a result, you can invokefilteron anNonEmptySet, even thoughfiltercould result in an empty sequence—but the result type will beSetinstead ofNonEmptySet:NonEmptySet(1, 2, 3).filter(_ < 10) // Result: Set(1, 2, 3) NonEmptySet(1, 2, 3).filter(_ > 10) // Result: Set()
You can use
NonEmptySets inforexpressions. The result will be anNonEmptySetunless you use a filter (anifclause). Because filters are desugared to invocations offilter, the result type will switch to aSetat that point. Here are some examples:scala> import org.scalactic.anyvals._ import org.scalactic.anyvals._ scala> for (i <- NonEmptySet(1, 2, 3)) yield i + 1 res0: org.scalactic.anyvals.NonEmptySet[Int] = NonEmptySet(2, 3, 4) scala> for (i <- NonEmptySet(1, 2, 3) if i < 10) yield i + 1 res1: Set[Int] = Set(2, 3, 4) scala> for { | i <- NonEmptySet(1, 2, 3) | j <- NonEmptySet('a', 'b', 'c') | } yield (i, j) res3: org.scalactic.anyvals.NonEmptySet[(Int, Char)] = NonEmptySet((1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c)) scala> for { | i <- NonEmptySet(1, 2, 3) if i < 10 | j <- NonEmptySet('a', 'b', 'c') | } yield (i, j) res6: Set[(Int, Char)] = Set((1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c))- T
the type of elements contained in this
NonEmptySet
- final class NonEmptyString extends AnyVal
A non-empty list: an ordered, immutable, non-empty collection of elements with
LinearSeqperformance characteristics.A non-empty list: an ordered, immutable, non-empty collection of elements with
LinearSeqperformance characteristics.The purpose of
NonEmptyStringis to allow you to express in a type that aStringis non-empty, thereby eliminating the need for (and potential exception from) a run-time check for non-emptiness. For a non-empty sequence withIndexedSeqperformance, seeEvery.Constructing
NonEmptyStringsYou can construct a
NonEmptyStringby passing one or more elements to theNonEmptyString.applyfactory method:scala> NonEmptyString(1, 2, 3) res0: org.scalactic.anyvals.NonEmptyString[Int] = NonEmptyString(1, 2, 3)
Alternatively you can cons elements onto the
Endsingleton object, similar to making aStringstarting withNil:scala> 1 :: 2 :: 3 :: Nil res0: String[Int] = String(1, 2, 3) scala> 1 :: 2 :: 3 :: End res1: org.scalactic.NonEmptyString[Int] = NonEmptyString(1, 2, 3)
Note that although
Nilis aString[Nothing],Endis not aNonEmptyString[Nothing], because no emptyNonEmptyStringexists. (A non-empty list is a series of connected links; if you have no links, you have no non-empty list.)scala> val nil: String[Nothing] = Nil nil: String[Nothing] = String() scala> val nada: NonEmptyString[Nothing] = End <console>:16: error: type mismatch; found : org.scalactic.anyvals.End.type required: org.scalactic.anyvals.NonEmptyString[Nothing] val nada: NonEmptyString[Nothing] = End ^Working with
NonEmptyStringsNonEmptyStringdoes not extend Scala'sSeqorTraversabletraits because these require that implementations may be empty. For example, if you invoketailon aSeqthat contains just one element, you'll get an emptySeq:scala> String(1).tail res6: String[Int] = String()
On the other hand, many useful methods exist on
Seqthat when invoked on a non-emptySeqare guaranteed to not result in an emptySeq. For convenience,NonEmptyStringdefines a method corresponding to every suchSeqmethod. Here are some examples:NonEmptyString(1, 2, 3).map(_ + 1) // Result: NonEmptyString(2, 3, 4) NonEmptyString(1).map(_ + 1) // Result: NonEmptyString(2) NonEmptyString(1, 2, 3).containsSlice(NonEmptyString(2, 3)) // Result: true NonEmptyString(1, 2, 3).containsSlice(NonEmptyString(3, 4)) // Result: false NonEmptyString(-1, -2, 3, 4, 5).minBy(_.abs) // Result: -1
NonEmptyStringdoes not currently define any methods corresponding toSeqmethods that could result in an emptySeq. However, an implicit converison fromNonEmptyStringtoStringis defined in theNonEmptyStringcompanion object that will be applied if you attempt to call one of the missing methods. As a result, you can invokefilteron anNonEmptyString, even thoughfiltercould result in an empty sequence—but the result type will beStringinstead ofNonEmptyString:NonEmptyString(1, 2, 3).filter(_ < 10) // Result: String(1, 2, 3) NonEmptyString(1, 2, 3).filter(_ > 10) // Result: String()
You can use
NonEmptyStrings inforexpressions. The result will be anNonEmptyStringunless you use a filter (anifclause). Because filters are desugared to invocations offilter, the result type will switch to aStringat that point. Here are some examples:scala> import org.scalactic.anyvals._ import org.scalactic.anyvals._ scala> for (i <- NonEmptyString(1, 2, 3)) yield i + 1 res0: org.scalactic.anyvals.NonEmptyString[Int] = NonEmptyString(2, 3, 4) scala> for (i <- NonEmptyString(1, 2, 3) if i < 10) yield i + 1 res1: String[Int] = String(2, 3, 4) scala> for { | i <- NonEmptyString(1, 2, 3) | j <- NonEmptyString('a', 'b', 'c') | } yield (i, j) res3: org.scalactic.anyvals.NonEmptyString[(Int, Char)] = NonEmptyString((1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c)) scala> for { | i <- NonEmptyString(1, 2, 3) if i < 10 | j <- NonEmptyString('a', 'b', 'c') | } yield (i, j) res6: String[(Int, Char)] = String((1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c)) - final class NonEmptyVector[+T] extends AnyVal
A non-empty list: an ordered, immutable, non-empty collection of elements with
LinearSeqperformance characteristics.A non-empty list: an ordered, immutable, non-empty collection of elements with
LinearSeqperformance characteristics.The purpose of
NonEmptyVectoris to allow you to express in a type that aVectoris non-empty, thereby eliminating the need for (and potential exception from) a run-time check for non-emptiness. For a non-empty sequence withIndexedSeqperformance, seeEvery.Constructing
NonEmptyVectorsYou can construct a
NonEmptyVectorby passing one or more elements to theNonEmptyVector.applyfactory method:scala> NonEmptyVector(1, 2, 3) res0: org.scalactic.anyvals.NonEmptyVector[Int] = NonEmptyVector(1, 2, 3)
Alternatively you can cons elements onto the
Endsingleton object, similar to making aVectorstarting withNil:scala> 1 :: 2 :: 3 :: Nil res0: Vector[Int] = Vector(1, 2, 3) scala> 1 :: 2 :: 3 :: End res1: org.scalactic.NonEmptyVector[Int] = NonEmptyVector(1, 2, 3)
Note that although
Nilis aVector[Nothing],Endis not aNonEmptyVector[Nothing], because no emptyNonEmptyVectorexists. (A non-empty list is a series of connected links; if you have no links, you have no non-empty list.)scala> val nil: Vector[Nothing] = Nil nil: Vector[Nothing] = Vector() scala> val nada: NonEmptyVector[Nothing] = End <console>:16: error: type mismatch; found : org.scalactic.anyvals.End.type required: org.scalactic.anyvals.NonEmptyVector[Nothing] val nada: NonEmptyVector[Nothing] = End ^Working with
NonEmptyVectorsNonEmptyVectordoes not extend Scala'sSeqorTraversabletraits because these require that implementations may be empty. For example, if you invoketailon aSeqthat contains just one element, you'll get an emptySeq:scala> Vector(1).tail res6: Vector[Int] = Vector()
On the other hand, many useful methods exist on
Seqthat when invoked on a non-emptySeqare guaranteed to not result in an emptySeq. For convenience,NonEmptyVectordefines a method corresponding to every suchSeqmethod. Here are some examples:NonEmptyVector(1, 2, 3).map(_ + 1) // Result: NonEmptyVector(2, 3, 4) NonEmptyVector(1).map(_ + 1) // Result: NonEmptyVector(2) NonEmptyVector(1, 2, 3).containsSlice(NonEmptyVector(2, 3)) // Result: true NonEmptyVector(1, 2, 3).containsSlice(NonEmptyVector(3, 4)) // Result: false NonEmptyVector(-1, -2, 3, 4, 5).minBy(_.abs) // Result: -1
NonEmptyVectordoes not currently define any methods corresponding toSeqmethods that could result in an emptySeq. However, an implicit converison fromNonEmptyVectortoVectoris defined in theNonEmptyVectorcompanion object that will be applied if you attempt to call one of the missing methods. As a result, you can invokefilteron anNonEmptyVector, even thoughfiltercould result in an empty sequence—but the result type will beVectorinstead ofNonEmptyVector:NonEmptyVector(1, 2, 3).filter(_ < 10) // Result: Vector(1, 2, 3) NonEmptyVector(1, 2, 3).filter(_ > 10) // Result: Vector()
You can use
NonEmptyVectors inforexpressions. The result will be anNonEmptyVectorunless you use a filter (anifclause). Because filters are desugared to invocations offilter, the result type will switch to aVectorat that point. Here are some examples:scala> import org.scalactic.anyvals._ import org.scalactic.anyvals._ scala> for (i <- NonEmptyVector(1, 2, 3)) yield i + 1 res0: org.scalactic.anyvals.NonEmptyVector[Int] = NonEmptyVector(2, 3, 4) scala> for (i <- NonEmptyVector(1, 2, 3) if i < 10) yield i + 1 res1: Vector[Int] = Vector(2, 3, 4) scala> for { | i <- NonEmptyVector(1, 2, 3) | j <- NonEmptyVector('a', 'b', 'c') | } yield (i, j) res3: org.scalactic.anyvals.NonEmptyVector[(Int, Char)] = NonEmptyVector((1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c)) scala> for { | i <- NonEmptyVector(1, 2, 3) if i < 10 | j <- NonEmptyVector('a', 'b', 'c') | } yield (i, j) res6: Vector[(Int, Char)] = Vector((1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c))- T
the type of elements contained in this
NonEmptyVector
Value Members
- object End
Object that can be used as an endpoint for
NonEmptyListconstruction expressions that use the cons (::) operator.Object that can be used as an endpoint for
NonEmptyListconstruction expressions that use the cons (::) operator.Here's an example:
scala> 1 :: 2 :: 3 :: End res0: org.scalactic.NonEmptyList[Int] = NonEmptyList(1, 2, 3)
Note that unlike
Nil, which is an instance ofList[Nothing],Endis not an instance ofNonEmptyList[Nothing], because there is no emptyNonEmptyList:scala> Nil.isInstanceOf[List[_]] res0: Boolean = true scala> End.isInstanceOf[NonEmptyList[_]] res1: Boolean = false
- object NonEmptyArray
Companion object for class
NonEmptyArray. - object NonEmptyList
Companion object for class
NonEmptyList. - object NonEmptyMap
Companion object for class
NonEmptyMap. - object NonEmptySet
Companion object for class
NonEmptySet. - object NonEmptyString
Companion object for class
NonEmptyString. - object NonEmptyVector
Companion object for class
NonEmptyVector.