Scala contains special functions such as value and call by name. It also has anonymous functions and higher-order functions, which are demonstrated here.
- [Instructor] So far, the functions that I've created here…are all what we call callByValue functions,…where the value of the argument is determined…before calling the function.…There is also a callByName type of function.…It takes a different format, it passes a code block…to the call, which is executed each time…the value is calculated.…I've already created some callBy functions here…in my CallBy.se file.…Let's switch over to there.…
The first definition is defining…a function called something,…and something does not take any parameters…and it has two things that it does.…The first thing that it does is it prints out the words…inside calling something, and notice the number five…is on the line below it.…Remember in Scala that the last value…will be the value returned, so actually,…five is a return type.…Below that, I have two other functions.…One is representing a callByValue,…which is what we've been doing so far.…
callByValue, in this case, is taking in an integer,…assigning it to the variable named x.…Inside the body, it prints out the message…
- 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?
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.