Learn how to create a class in Scala. When you create a class in Scala, it automatically creates a primary constructor and the getter/setter methods for any fields declared in the class.
- In Scala when we create a class…it automatically creates a primary constructor…and the corresponding getter and setter methods…for any fields declared in the class.…In your exercise files folder, chapter 04 > 04_01…you'll have a starting program called payroll.scala.…It's just a template that you see here…that has the payroll extends app.…What we're going to do, is we're going to add a class,…so when you're dealing with payroll…you're dealing with employees.…So we're going to add a class to represent an employee…and then in our payroll in our main method there…we're going to create some employees…and print out their information.…
Let's start by adding the class.…I'm going to put it down here below my object for payroll…and I use the keyword class all in lowercase letters…and in this case I'm going to call it employee.…And then in the parameters we're…going to need some information about the employee,…we're going to need to know what is their first name…and that's going to be of type string.…We'll need to know their last name…
Join Peggy Fisher as she helps get you started with Scala, so you can leverage the unique capabilities it offers. First, learn the basics of type inference, variables, loops, functions, and operators. Then, find out how to read files using a console, perform pattern matching, handle exceptions, and more. Finally, learn how to use classes, fields, methods, and objects.
- Integrating with IDEs
- Scala worksheets
- Scala repl sessions
- Type inference
- Creating variables
- Working with loops
- Higher-order functions
- Scala operators
- Working with decision statements
- Handling exceptions using try or catch
- Working with tuples and arrays
- Classes, fields, and methods
Skill Level Intermediate
Java Platforms Compared: SE vs EE vs MEwith Peggy Fisher25m 38s Intermediate
Scala Essential Training for Data Sciencewith Dan Sullivan1h 51m Intermediate
1. Getting Started with 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?
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.