码迷,mamicode.com
首页 > 其他好文 > 详细

match

时间:2018-07-07 22:38:33      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:ack   next   def   com   case   hello   any   class   less   

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

标签:ack   next   def   com   case   hello   any   class   less   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!