progs/lecture1.scala
changeset 364 18942af74fa1
parent 361 736a60afedbc
child 367 24f86eb53259
equal deleted inserted replaced
363:9f481fd7c613 364:18942af74fa1
   520 // There are also a massive number of Scala tutorials on youtube
   520 // There are also a massive number of Scala tutorials on youtube
   521 // and there are tons of books and free material. Google is your 
   521 // and there are tons of books and free material. Google is your 
   522 // friend.
   522 // friend.
   523 
   523 
   524 
   524 
   525 
       
   526 
       
   527 
       
   528 // declarative 
       
   529 
       
   530 users.filter(_.email.endsWith("@gmail.com"))
       
   531 
       
   532 // imperative
       
   533 
       
   534 val result = ListBuffer[User]()
       
   535 for(user <- users) {
       
   536     if(user.email.endsWith("@gmail.com")) {
       
   537         result += user
       
   538     }
       
   539 }
       
   540 result.toList
       
   541 
       
   542 
       
   543 
       
   544 
       
   545 
       
   546 
       
   547