12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
编程知识 时间:2024-12-04 20:26:52
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
在Scala中,模式匹配的方法主要有两种:使用match关键字和case语句进行模式匹配,以及使用match方法和case语句进行模式匹配。具体示例如下:使用match关键字和case语句进行模式匹配
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
在Scala中,模式匹配的方法主要有两种:使用match
关键字和case
语句进行模式匹配,以及使用match
方法和case
语句进行模式匹配。具体示例如下:
match
关键字和case
语句进行模式匹配:val x: Any = 10x match {case 1 => println("One")case 2 => println("Two")case _ => println("Other")}
match
方法和case
语句进行模式匹配:val x: Any = 10x match {case 1 => println("One")case 2 => println("Two")case _ => println("Other")}
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19