A Scala method is a part of a class that has a name and a signature, whereas a function in Scala is a complete object that can be assigned to a variable. Learn more about Scala functions and methods in this video.
- [Narrator] Defining functions in Scala.…Scala has both functions and methods.…A Scala method is part of a class…that has a name and a method signature,…whereas a function in Scala is a complete object…that can be assigned to a variable.…A function definition can appear anywhere…in a source file.…We already know that Scala…is a functional programming language.…To create a function in Scala, we use the d-e-f keyword…to tell the compiler that this is a function.…
There are several types of functions that we can use,…and Scala makes it easy to use anonymous functions,…which are also called lambda functions.…The general format for a function is the function name…followed by parentheses with any input arguments,…which might be zero, one, or many,…colon, and then an optional return type…equals the body of the function.…Functions can be designed to return one or more values,…but some functions do not return any values.…Instead, they return what we call a Unit type.…
This is similar to Java's void function, or void method.…
- 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.