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

org.scalactic.anyvals.End.scala Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2001-2017 Artima, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.scalactic.anyvals

/**
  * Object that can be used as an endpoint for NonEmptyList construction 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 of List[Nothing], * End is not an instance of NonEmptyList[Nothing], because there is * no empty NonEmptyList: *

* *
  * scala> Nil.isInstanceOf[List[_]]
  * res0: Boolean = true
  *
  * scala> End.isInstanceOf[NonEmptyList[_]]
  * res1: Boolean = false
  * 
*/ object End { /** * A :: operator that serves to start a NonEmptyList construction * expression. * *

* The result of calling this method will always be a NonEmptyList of length 1. * Here's an example: *

* *
    * scala> 1 :: End
    * res0: org.scalactic.NonEmptyList[Int] = NonEmptyList(1)
    * 
*/ def ::[T](element: T): NonEmptyList[T] = NonEmptyList(element) /** * Returns "End". */ override def toString: String = "End" }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy