Skip to main content

Posts

Showing posts from September, 2010

Scala :: multiple traits mix-in

Scala allow the multiple trait mix-in.
On the Java, java also allow the multiple interface implementation. What is the difference between Scala's trait and Java's interface? There are similar thing. We use trait as interface define. But, trait can have it own field and implementation of there defined method. Java's interface cannot it own some values and implementations that the interface defined the methods.
I had a question about trait mix-in. The question is "when some of traits are defined same name of methods and the methods also have some different implements then which method will be active?" For example, --------------------------------------------------------- trait A { def x = println("A......x")} trait B { def x = println("B......x")}
class C extends A with B class D extends B with A --------------------------------------------------------- In such case, trait A and B define the method named x. And both x on each trait have also imple…