From the course: Learning JVM Languages: JVM, Java, Scala
Unlock this course with a free trial
Join today to access over 22,500 courses taught by industry experts.
Functional programming in Scala
From the course: Learning JVM Languages: JVM, Java, Scala
Functional programming in Scala
- [Instructor] Hi guys, we're at the sixth video, functional programming in Scala. Previously we looked at Scala's functional library. In this video we'll look at several function program related topics such as iterating through collections using functions. The map, filter and reduce design pattern, and currying. Let's start with iterating through collections using functions. In functional programming it's unusual to use both for or while loops to iterate through arrays and collections and process each item inside the loop's body. Instead a method is called on the array or collection instance, which internally iterates through the array all collection. This method takes a lambda function as a parameter and ensures that the function is called for each item. So let's add the code here and run it. This prints 005 010 015 020 and 025. It uses the format method of java's java dot lang dot string class to ensure that printed integer has up to three leading zeros. Now we'll learn about the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.