learning scala view collection

The view method will create a non-strict version of the collection which means that the elements of the collection will only be made available at access time.

 

val lazyLargeOddNumberList = (1 to 1000000).view.filter(_ % 2 != 0).take(10).toList

 

posted @ 2019-07-15 09:03  嵌入式实操  阅读(81)  评论(0编辑  收藏  举报