Scala Interview Question: What Are Case Classes and where are they used?

Описание к видео Scala Interview Question: What Are Case Classes and where are they used?

Case classes in Scala are a special type of class that comes with several built-in features and are designed primarily for modelling immutable data. While building applications, we use case class to define a schema.
Features of Case class:
• Case class cannot inherit another case class
• It supports pattern matching
• No need to use the new Keyword to initiate the case class
• By default, case class creates a companion object. Companion objects are those objects that have the same name as that of the class. So if an object name is singletonExample and its class name is also singletonExample, we say that the object is a companion object and the class is a companion class
• All the arguments in case class will be val
• Case class are immutable. They are helpful for modelling immutable data. They are mainly used for defining schema

Комментарии

Информация по комментариям в разработке