Hello everybody,
I am puzzled by the execution sequence of the following scala program. Please
tell me if it run in the same sequence on your computer,.and it is normal.
Thanks
execution sequence according to line number:
26-7-20-27-9-10-12-13-15-7-20-17-18-9-10-12-13-15-7-20-17-18
1.
import scala.collection.mutable.ArrayBuffer
2.
3.
object TestCase1{
4.
5.
def func(testtttt:Iterator[(Int,Long)]): Iterator[(Int,Long)]={
6.
7.
println("in")
8.
val testtttt1=testtttt.flatmap{
9.
case(item,count)=>
10.
val newPrefix=item
11.
12.
println(count)
13.
val a=Iterator.single((newPrefix,count))
14.
15.
func(a)
16.
17.
val c = a
18.
c
19.
}
20.
testtttt1
21.
}
22.
23.
def main(args: Array[String]){
24.
val freqItems = ArrayBuffer((2,3L),(3,2L),(4,1L))
25.
val testtttt = freqItems.toIterator
26.
val result = func(testtttt)
27.
val reer = result.toArray
28.
29.
}
30.
}