Box[A]=A ãåºæ¥ãä¸æè°
Liftã®ãã¡ã¤ã«ã¢ãããã¼ãã®ãµã³ãã«ã³ã¼ãã§
var fileHolder : Box[FileParamHolder] = Empty (ç¥) bind(... "receipt" -> SHtml.fileUpload(fileHolder = _),
ã¨ããé¨åããããSHtml.fileUpload()ã®ä»æ§ãè¦ãã¨ãå¼æ°å㯠FileParamHolder => Any ã¨ãããã¨ã§ãé¢æ°ãªãã©ã«ã®å 容ã¯ãã¨ããã¨ãåçã«ã¯ä»¥ä¸ã®ãããªé¢ä¿ã«ãªãã¯ãã(ããã¯ããã¾ã§ä¾ãªã®ã§æå³ã®ããã³ã¼ãã§ã¯ããã¾ãã)
Box[FileParamHolder] = FileParamHolder
ãªãã§ãããªãã¨åºæ¥ãã®ãããã¾ã®ã¨ããããããããªãããã£ãã調ã¹ã¦ã¿ã¦æ°ãã¤ãããã¨
- Box[T] 㯠Product trait ãå®è£ ãã¦ãã
- FileParamHolder 㯠Product trait ãå®è£ ãã¦ãã
- FileParamHolderã®ã½ã¼ã¹ã«ã¯ with Product ãªã©ã¨ã¯æ¸ããã¦ããªã
ããããä¸è¨ã®ãããªä»£å
¥ãåºæ¥ãã®ã¯ãªãããã¨ããçåã« Product trait ãé¢ä¿ãã¦ãããã©ããã¯ã¾ã£ããä¸æã
ã§ããProductã£ã¦ä½? ãªãã§åæã« with Product ã«ãªã£ã¦ãã®ã¨æã£ã¦ããããå®é¨ãã¦ã¿ãã
scala> case class A(); defined class A scala> (new A).isInstanceOf[Product] res1: Boolean = true scala> class B(); defined class B scala> (new B).isInstanceOf[Product] res2: Boolean = false
ã©ããã case class ã¯èªåçã« with Product ã¨ãããããã ããµããµããã§ãProductã£ã¦ä½ããã¨ãã話ã¯ã¾ã åå¼·ä¸ã