Nov 18, 2016 00:03
scala> val isEven: PartialFunction[Int,String] = {case x if x % 2 == 0 => x + " is even"}
isEven: PartialFunction[Int,String] =
scala> isEven(4)
res0: String = 4 is event
scala> isEven('x')
res1: String = 120 is even
Серьезно?
Очень давно не использовал этот язык, а тут вдруг полез зачем-то.
scala
Leave a comment
Comments 5
Reply
Reply
http://ideone.com/IngdBy
Reply
Reply
Reply
Leave a comment