|
Scala example source code file (bug2552.scala)
The Scala bug2552.scala source codeobject Test extends App { def testTakeWhile = { val numbers = Iterator.range(0, 50) val zeroTo9 = numbers.takeWhile(x => { println("p(" + x + ")"); x < 10 } ) zeroTo9.foreach(println _) val zeroTo1 = Iterator.range(0, 20).takeWhile(x => { println("p(" + x + ")"); x < 2 } ) println(zeroTo1.hasNext) println(zeroTo1.hasNext) println(zeroTo1.next) println(zeroTo1.hasNext) println(zeroTo1.next) println(zeroTo1.hasNext) println(zeroTo1.hasNext) } def testFilter = { val predicate = (x: Int) => { println("p(" + x + ")"); x % 2 == 0 } val evens = Iterator.range(0, 10).filter(predicate) println(evens.hasNext) println(evens.hasNext) println(evens.next) evens.foreach(println _) } testTakeWhile testFilter } Other Scala examples (source code examples)Here is a short list of links related to this Scala bug2552.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.