A keyword to skip the current iteration in a collection comprehension block.
- Authors
杨博 (Yang Bo)
- See also
Each for creating collection comprehensions.
- Note
- Example
Each and Continue can be used to calculate composite numbers and prime numbers.
import com.thoughtworks.dsl.bangnotation._ def compositeNumbersBelow(maxNumber: Int) = *[collection.immutable.HashSet] { val factor = !Each(2 until math.ceil(math.sqrt(maxNumber)).toInt) !Each(2 * factor until maxNumber by factor) } compositeNumbersBelow(13) should be(Set(4, 6, 8, 9, 10, 12)) def primeNumbersBelow(maxNumber: Int) = *[Seq] { val compositeNumbers = compositeNumbersBelow(maxNumber) val i = !Each(2 until maxNumber) if (compositeNumbers(i)) !Continue i } primeNumbersBelow(13) should be(Array(2, 3, 5, 7, 11))
- Companion
- class
Type members
Inherited types
Value members
Inherited methods
Givens
Givens
Implicits
Implicits
implicit
def OptionContinueDsl[Value, Element](implicit factory: Factory[Element, Option[Element]]): Dsl[Continue, Option[Element], Value]
implicit
def collectionContinueDsl[Value, Element, Collection[_]](implicit factory: Factory[Element, Collection[Element]]): Dsl[Continue, Collection[Element], Value]