• foreach
val xs = List("date", "since", "other1", "other2")

xs.foreach { str =>

    str match {
        case "date"  => println("Match Date")
        case "since" => println("Match Since")
        case unknow  => println("Others")
    } 

    println("Put your post step here")
}

注意:如果要使用一段代码作为foreach()的参数,则应使用{}而不是()。

Share on: TwitterFacebookEmail

Comments


Related Posts


Published

Category

Programming

Tags

Contact