progs/lecture3.scala
changeset 170 37b1bfcdba79
parent 158 94b11ac19b41
child 178 fdf77ee57cdc
equal deleted inserted replaced
169:b37052895281 170:37b1bfcdba79
   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`