File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,3 @@ Iteration 7
9
9
Iteration 8
10
10
Iteration 9
11
11
42
12
-
Original file line number Diff line number Diff line change
1
+ Iteration 0
2
+ Iteration 1
3
+ Iteration 2
4
+ Iteration 3
5
+ Iteration 4
6
+ Iteration 5
7
+ Iteration 6
8
+ Iteration 7
9
+ Iteration 8
10
+ Iteration 9
11
+ Lzy has been read as: 42
12
+ Lzy has been read as: 43
13
+ Lzy has been read as: 44
14
+ Lzy has been read as: 45
15
+ Lzy has been read as: 46
16
+ Lzy has been read as: 47
17
+ Lzy has been read as: 48
18
+ Lzy has been read as: 49
19
+ Lzy has been read as: 50
20
+ Lzy has been read as: 51
21
+ 52
22
+ Lzy has been read as: 52
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ var count : Int = 0
3
+ def getLzy = {
4
+ val read = lzy
5
+ println(" Lzy has been read as: " + read)
6
+ read
7
+ }
8
+
9
+ lazy val lzy : Int = {
10
+ if (count < 10 ) {
11
+ println(s " Iteration $count" )
12
+ count += 1
13
+ getLzy + 1
14
+ } else 42
15
+ }
16
+
17
+ def main (args : Array [String ]): Unit = {
18
+ println(lzy)
19
+ getLzy
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments