Scala 2.10.0 M3ã®æ–°æ©Ÿèƒ½ã‚’試ã—ã¦ã¿ã‚‹è¨˜äº‹ç¬¬äºŒæ®µã€‚今度ã¯SIP-13 - Implicit classesã§ã™ã€‚ ã•ã¦ã€Scalaã§ã¯å¾“æ¥ã€implicit conversionを使ã£ã¦ã€æ—¢å˜ã®ã‚¯ãƒ©ã‚¹ã«ãƒ¡ã‚½ãƒƒãƒ‰ã‚’è¿½åŠ ã™ã‚‹Pimp My Libraryã¨å‘¼ã°ã‚Œã‚‹ãƒ‘ターンãŒä½¿ã‚ã‚Œã¦ãã¾ã—ãŸã€‚ãŸã¨ãˆã°ã€Stringã«å¯¾ã—ã¦ã€æ–‡å—列を表示ã™ã‚‹displayãƒ¡ã‚½ãƒƒãƒ‰ã‚’è¿½åŠ ã™ã‚‹ãŸã‚ã«ã¯ã€æ¬¡ã®ã‚ˆã†ãªã‚³ãƒ¼ãƒ‰ã‚’書ãå¿…è¦ãŒã‚ã‚Šã¾ã—ãŸã€‚ scala> class RichString(self: String) { | def display(): Unit = println(self) | } defined class RichString scala> implicit def enrichString(self: String): RichString = new RichString(s
{{#tags}}- {{label}}
{{/tags}}