首页 > 其他 > 详细

match

时间:2018-07-07 21:23:01      阅读:164      评论:0      收藏:0      [点我收藏+]
package com.bjsxt.scala

object Lesson_match {
  def main(args: Array[String]): Unit = {
    val tuple = (1,"hello",‘c‘,1.0,true)
    val iter = tuple.productIterator
    while(iter.hasNext){
      val one = iter.next()
      MatchTest(one)
    }
  }
  
  def MatchTest(o:Any)=
    o match {
      case i:Int=>{println("type is Int")}
      case d:Double=>{println("typle is Double")}
      case 1=>{println("value is 1")}
      case ‘c‘=>{println("value is c")}
      case s:String=>{println("type is String")}
      case _=>{println("no match ... ")}
    }
  
  
}

  

match

原文:https://www.cnblogs.com/huiandong/p/9278284.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!