Skip to content

Instantly share code, notes, and snippets.

@e2kaneko
Created September 30, 2012 06:03
Show Gist options
  • Save e2kaneko/3806009 to your computer and use it in GitHub Desktop.
Save e2kaneko/3806009 to your computer and use it in GitHub Desktop.
GroovyのMixin(ミックスイン)
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