optionåã«ã¤ãã¦ãããå°ã調ã¹ã¦ã¿ã¾ããã ååã使ãã«ãããªã¨è¨ã£ã¦ããã¨ããã¯ãgetOrElseãorElseã使ãã°ã ãã¶æ¹åãããã¿ããã§ãã getOrElseã¯æãã¦ããã ããã®ã§ãorElseã調ã¹ã¦ã¿ã¾ããã object OptionTest2{ val capitals = Map("France" -> "Paris", "Japan" -> "Tokyo", "" -> "Unknown") def get(x:String) = ({capitals get x} orElse (capitals get "")).get def main(args: Array[String]) { println (get("Japan")) println (get("North Pole")) } } çµæ scala OptionTest2 Tokyo Unkn
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}