Created
September 30, 2012 06:03
-
-
Save e2kaneko/3806009 to your computer and use it in GitHub Desktop.
GroovyのMixin(ミックスイン)
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
| package com.e2info.groovy | |
| class Hello { | |
| static hello(String arg) { | |
| println "hello $arg." | |
| } | |
| } | |
| class Bye { | |
| static bye(String arg){ | |
| println "bye $arg." | |
| } | |
| } | |
| String.mixin(Hello) | |
| String.mixin(Bye) | |
| "world".hello() | |
| "world".bye(); | |
| /* | |
| hello world. | |
| bye world. | |
| */ | |
| String.mixin(String) // これも大丈夫(意味ないけど) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment