Created
April 14, 2012 07:10
-
-
Save yangbajing/2382583 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def opt(paramA: Option[String], paramB: Option[Date], paramC: Option[Int]): Option[String] = { | |
| for ( | |
| a <- paramA; | |
| b <- paramB; | |
| c <- paramC) yield { | |
| a + " | " + b + " | " + c | |
| } | |
| } | |
| println(opt(Some("羊八井", Some(new Date), Some(26))) | |
| println(opt(None, Some(new Date), Some(26))) | |
| println(opt(None, Some(new Date), Some(26)).getOrElse("我设个默认值")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment