Learn how to read data from the user, in Scala. We use the Scala.io.StdIn which provides several methods that make it easy to write code that allows the user to interact with your program.
- [Narrator] Sometimes it's helpful…to allow the user to interact with the program.…We can do this by reading information from the Console.…In Scala, in order to read information from the Console…we have to use the Scala.io.StdIn library…which provides several methods…to read from the Console.…We have readBoolean, which returns a Boolean,…readByte, readChar,…we also have readDouble,…readInt, readLine, which returns a string…and there's a variation on readLine,…which is very useful,…that allows us to prompt the user,…by placing the prompt…inside the parenthesis of the readLine method.…
And that returns a string.…Let's switch over to the Scala IDE…and take a look at how to read data from the Console.…In your exercise files folder,…in chapter 03-03-01,…you'll see there's a grades dot scala,…a program template in there.…If you open it up,…it should look like what you see here.…It should have the import statement at the top,…that allows us to use those read methods…that we just saw.…And then it declares an object called grade,…
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.