@Typed
package categoriestest
@Category(List)
@Typed
class Shuffler {
def shuffleit() {
def result = new ArrayList(this)
Collections.shuffle(result)
result
}
}
// @Mixin(Shuffler)
@Typed
class Sentence extends ArrayList {
Sentence(Collection initial) { super(initial) }
}
@Typed
class Main {
static main(args) {
def words = ["The", "quick", "brown", "fox"]
Sentence.mixin Shuffler.class
def sentence = new Sentence(words)
println sentence.shuffleit()
}
}
Main.main(null)
http://gppconsole.appspot.com/script/20001
No comments:
Post a Comment