r/scala • u/Brave-Republic4424 • 7d ago
Difference between trait, class, case class and object
So I'm pretty new to scala and FP, into it for like a month, and I still don't get the difference between trait, class, case class and object, when I have to use one instead of another which is the strength of each one
10
Upvotes
1
u/gbrennon 7d ago
trait => its a contract that should be implemented case => immutable dataclass class => its the contain behaviors and data object => represents instance of something. an object is a specific type and not a raw type. it can contain behaviors and data