| changeset 170 | 3d760b06befa |
| parent 158 | f60e0908f80b |
| child 178 | 55367d499635 |
--- a/progs/lecture3.scala Fri Jan 19 14:09:08 2018 +0000 +++ b/progs/lecture3.scala Fri Feb 23 22:26:42 2018 +0000 @@ -509,3 +509,20 @@ // I like best about Scala that it lets me often write // concise, readable code. + + +// You can define your own while loop + + +def my_while(condition: => Boolean)(block: => Unit): Unit = + if (condition) { block ; my_while(condition) { block } } else { } + + +var x = 10 +my_while (x > 0) { + println(s"$x") ; x = x - 1 +} + + +`symbol +`symbol`