This is your very first post. Click the Edit link to modify or delete it, or start a new post. If you like, use this post to tell readers why you started this blog and what you plan to do with it.
Author: corerootz - Ravi Kiran Krovvidi
Scala – Difference between Classes and traits
Difference – 1
class Employee(x: Int, y: Int) {}
trait Learning (x: Int, y: Int) {} // Does not compile
Difference – 2
In classes – super calls are statically bound, in traits, they are dynamically bound. If
you write “super.toString” in a class, you know exactly which method
implementation will be invoked.
In Trait – When you write the same thing in a trait, the method implementation to invoke for the super call is undefined when you define the trait. Rather, the implementation to invoke will be determined anew each time the trait is mixed into a concrete class. This
allows traits to work as stackable modifications!!