Reader small image

You're reading from  Learning Scala Programming

Product typeBook
Published inJan 2018
Reading LevelBeginner
PublisherPackt
ISBN-139781788392822
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Vikash Sharma
Vikash Sharma
author image
Vikash Sharma

Vikash Sharma is a software developer and open source technology evangelist. He tries to keep things simple, which helps him write clean and manageable code. He has invested a large amount of time learning and implementing Scala code, and he has authored video courses for Scala. He works as a developer at SAP Labs.
Read more about Vikash Sharma

Right arrow

Implicits - what and why


What are implicits? When we talk about implicits, we mean implicit parameters or conversions that happen implicitly. Implicit parameters are the ones that come along with a keyword, implicit, and we don't have to explicitly pass an argument for these parameters if they were in Scope. Let's see how.

Let's take an example, and create a Future value. A Future is nothing but a computation (that we provide) that's going to happen at a later point in time. It means a computation that's going to happen in the future. We'll talk about Future values in depth when we discuss concurrent programming techniques in Chapter 13, Concurrent Programming in Scala. Let's write a code snippet for now:

import scala.concurrent.Future 
 
object FuturesApp extends App { 
 
  val futureComp = Future { 
     1 + 1 
  } 
 
  println(s"futureComp: $futureComp") 
 
  futureComp.map(result => println(s"futureComp: $result")) 
} 

Okay, we are not sure about how this Future thing works, but from...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning Scala Programming
Published in: Jan 2018Publisher: PacktISBN-13: 9781788392822

Author (1)

author image
Vikash Sharma

Vikash Sharma is a software developer and open source technology evangelist. He tries to keep things simple, which helps him write clean and manageable code. He has invested a large amount of time learning and implementing Scala code, and he has authored video courses for Scala. He works as a developer at SAP Labs.
Read more about Vikash Sharma