val times =1times match {case1=>"one"case2=>"two"case _ =>"some other number"}//Matching with guardstimes match {case i if i ==1=>"one"case i if i ==2=>"two"case _ =>"some other number"}//Matching on Typedefbigger(o: Any): Any = { o match {case i: Int if i <0=> i -1case i: Int => i +1case d: Double if d <0.0=> d -0.1case d: Double => d +0.1case text: String => text +"s" }}
Case Classes
convenientaly store and match on class contents(i.e insted of if comp.brand == "HP")