Case classes are defined by adding the case keyword before the class keyword. Using this approach does the following: prepends val to all parameters, making them immutable instance values. Learn how to take advantage of Scala language to automate this ana
- (Narrator) In Scala, there's a special type of class…called a Case Class.…Case Classes are defined similar to a class,…but instead, they add the Case keyword before the…Class keyword, as you see in Line 4.…By doing that, it automatically does the equivalent…of the following: It prepends VAL to all parameters…making them immutable instance values.…It creates equals in Hash Code Methods…so that instances of that class…can safely be used in collections.…
It creates a companion object of the same name…with an apply method with the same arguments…as declared for the class.…This allows creation of instances without using…the new keyword and with an apply method…to allow the class name to be used…as an extractor in case statements.…Case classes are immutable by default,…decomposable through pattern matching,…compared by structural equality instead of by reference,…succinct to instantiate and operate on.…
Let's take a closer look at our example that we have here.…In this one, I have Case Class, Money,…which has two parameters, an amount and a currency.…
- Installing Scala
- Integrating with IDEs
- Creating variables
- Using special functions
- Basic types and operations
- Tuples, sets, maps, arrays, and lists
- Classes, fields, and methods
- Singleton objects
Skill Level Intermediate
1. Why Scala?
2. Scala Basics
3. More Scala Basics
4. Objects with Scala
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.