This video presents a solution to creating a program in Scala that uses an array of numbers. The solution includes writing functions to find the average of all numbers in the list and the min and max values.
- [Instructor] Welcome back.…How did you make out with this challenge?…I hope you had fun and I hope you didn't get frustrated.…What I'd like to do is walk you through my version…of the solution to this…and explain my thought process along the way.…So let's start by creating a Scala project.…And I'm going to call this array challenge.…Inside my SRC folder, I need to add a new scala app.…And I'll call this array challenge as well.…Alright, inside my code,…I needed to create three different functions.…
One that will find the average of an array,…one will find the minimum value in an array,…and another one that will find…the maximum value in an array.…I'm going to start by defining a function called average.…So I'm going to do def avg,…it takes in an array of type int that needs a name,…so I'll do a:, and now I specify the data type, array[Int[)…Because I want to return the average,…I'm going to return a double.…Because I want the average to include the decimal portion.…
This is equal to an open curly bracket,…and first I know in order to calculate the average,…
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?
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.