Scalaã«ã¯ãPartialFunctionã¨ãããã®ãããã¾ãã ç´è¨³ããã¨é¨åé¢æ°ã§ãããããã¯ãªã«ãã£ã¦ããã¨ãç¹å®ã®å¼æ°ã«å¯¾ãã¦ã¯çµæãè¿ããã©ãçµæãè¿ããªãå¼æ°ããããããªä¸éå端ãªé¢æ°ãã§ãã ã©ããã£ã¦ä½¿ãã®ã? ã¾ããã¡ãã£ã¨ä¾ãè¦ã¦ã¾ãããããPartialFunctionã§ããfooPfã¯ãå¼æ°ã"foo"ã ã£ãã"bar"ãè¿ãã¦ã"foo"以å¤ã¯ç¥ããã¨ããã¦ãã¨ã¼ãªé¢æ°ã§ãã scala> val fooPf:PartialFunction[String,String] = { case "foo" => "bar" } fooPf: PartialFunction[String,String] = <function1> scala> fooPf("foo") res5: String = bar scala> fooPf("hoge") scala.Mat
{{#tags}}- {{label}}
{{/tags}}