scala> //PS:117 scala> //psn > a40 > a40 scala> //Argument List is pattern matched using scala> //<variable name> @ _* scala> def CheckSequence(myData: Seq[Char]) = myData match { | case Seq('a', 'b', otherVals @ _*) => true | case _ => false | } CheckSequence: (myData: Seq[Char])Boolean scala> scala> val data1 = Seq('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') data1: Seq[Char] = List(a, b, c, d, e, f, g, h) scala> println(s"Result -> ${CheckSequence(data1)}") Result -> true scala> scala> val data1 = Seq('m', 'n', 'o', 'p', 'q') data1: Seq[Char] = List(m, n, o, p, q) scala> println(s"Result -> ${CheckSequence(data1)}") Result -> false
No comments:
Post a Comment