原创文章,转载请注明出处!

原文地址: http://www.ptbird.cn/2016/07/19/scala-chuji-demo-27

There I am,in the world more exciting!

by postbird

www.ptbird.cn



package com.ptbird.scala /** * Created by postbird on 2016/5/26. */ object ExtratorTest { def main(args: Array[String]): Unit = { def match_array(arr: Any) = arr match { case Array(0) => println("Array " + "0") case Array(x, y) => println("Array " + "x" + "y") case Array(0, _*) => println("Array " + "0........") case _ => println("Array " + " other") } // match_array(Array(0, 2, 3, 4)) //Array 0........ // match_array(Array(0)) //Array 0 var pattern = "([0-9]+) ([a-z]+)".r "2013123 scala" match{ //正则表达式的提取器 case pattern(num,item)=>println(num+" : "+item) // 2013123 : scala } } }