lazy val l = 1/0
print("111")
print(l) 执行这一句才会报错
===== 流(懒值) =====
def f(n:Int):Stream[Int] = n #:: f(n+1)
var a= f(0)
println(a)
println(a.tail)
println(a.take(3).force)(强制去取个值)
结果:
Stream(0, ?)
Stream(1, ?)
Stream(0, 1, 2)
===== 懒视图 =====
var v= (0 to 100).view.map(_+1)
println(v(1))