progs/lecture3.scala
changeset 170 3d760b06befa
parent 158 f60e0908f80b
child 178 55367d499635
equal deleted inserted replaced
169:8a1bd8ddb96c 170:3d760b06befa
   507 List(1, 2, 3) contains "your mom"
   507 List(1, 2, 3) contains "your mom"
   508 
   508 
   509 // I like best about Scala that it lets me often write
   509 // I like best about Scala that it lets me often write
   510 // concise, readable code.
   510 // concise, readable code.
   511 
   511 
       
   512 
       
   513 
       
   514 // You can define your own while loop
       
   515 
       
   516 
       
   517 def my_while(condition: => Boolean)(block: => Unit): Unit = 
       
   518   if (condition) { block ; my_while(condition) { block } } else { }
       
   519 
       
   520 
       
   521 var x = 10
       
   522 my_while (x > 0) { 
       
   523   println(s"$x") ; x = x - 1 
       
   524 }
       
   525 
       
   526 
       
   527 `symbol
       
   528 `symbol`