大数据系列修炼-Scala课程28
核心内容:
1、scala中提取器Extractor实战解析
1、scala中提取器Extractor实战解析 |
1>scala中的提取器Extractor指的是从case表达式中提取相应数值的过程
2>在match……case中,用常量可以接受到要匹配的数值,并且在=>后面可以提取出相应的数值
3>利用正则表达式可以提取出已经分组的数据
实例程序:
object App
{
def main(args:Array[String]):Unit=
{
//实例1
def fun1(t:Any) = t match
{
case Array(x) => println(""+ x)
case Array(x,y) => pri