app2.scala
changeset 7 bd2b16f82601
parent 6 4c40d4b2d01c
equal deleted inserted replaced
6:4c40d4b2d01c 7:bd2b16f82601
     1 object Application extends Controller {
     1 object Application extends Controller {
     2 
     2 
     3   def gt_cookie(c: Option[Cookie]) : Int = c match {
     3   def gt_cookie(c: Option[Cookie]) : Int = c.map(_.value) match {
     4     case Some(s) if (s.value.forall(_.isDigit)) => s.value.toInt 
     4     case Some(s) if (s.forall(_.isDigit)) => s.toInt 
     5     case _ => 0
     5     case _ => 0
     6   }
     6   }
     7 
     7 
     8   def mk_cookie(i: Int) : Cookie = {
     8   def mk_cookie(i: Int) : Cookie = {
     9     Cookie("visits", i.toString)
     9     Cookie("visits", i.toString)