This video covers the process of defining your own functions. Since Scala is a functional programming language this is a key topic to using Scala efficiently. This video explores the syntax and demonstrates examples of writing your own functions.
- [Instructor] Let's take a look at…defining functions in Scala.…Scala has both functions and methods and their syntax…is exactly the same.…A Scala method is part of a class…that has a name and a signature.…Whereas a function in Scala is a complete object…that can be a sign to a variable.…In Scala a method performs on an object,…a function does not.…A function definition can appear anywhere in a file.…Remember Scala is considered a…functional programming language.…
To create a function in Scala,…lets take a look at the syntax.…We start with the keyword def,…then we have the function name…followed by any input parameters…that are coming in from the calling program.…A colon and a return type equals…then the body of the function.…There are several types of function that we can use,…and Scala makes it easy to use anonymous functions,…which are also called lambda functions.…When coding a function if you don't see the equal sign,…it will automatically be considered a unit function.…
Or what we might call in Java a void function.…
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
1. Getting Started with Scala
2. Scala Basics
3. More Scala Basics
5. 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.