Duck Typing - Groovin' with Groovy | [ Prev | Home | Next ] |
class Duck { quack() { println "I am a Duck" } } class Frog { quack() { println "I am a Frog" } } quackers = [ new Duck(), new Frog() ] for (q in quackers) { q.quack() }
(Example 8)
Copyright 2004 by Jim Weirich (Some Rights Reserved) |