Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

怖くない!Implicit!

604 views

Published on

2018/11/29に(株)ネクストビート様で行われた #scala_rookies のLT資料です。
https://scala-rookies.connpass.com/event/105904/

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

怖くない!Implicit!

  1. 1. ⇢ ⇢ ⇢ ⇢ ⇢ ⇢ ⇢
  2. 2. 
 
 
 
 
 
 
 
 

  3. 3.
  4. 4. // `ExecutionContext` 
 def getEmployee(id: Int)(implicit e: ExecutionContext): Future[Employee] = ??? def getRole(employee :Employee)(implicit e: ExecutionContext): Future[Role] = ???
  5. 5. // `ExecutionContext` 
 def getEmployee(id: Int)(implicit e: ExecutionContext): Future[Employee] = ??? def getRole(employee :Employee)(implicit e: ExecutionContext): Future[Role] = ???
  6. 6. // `ExecutionContext` 
 def getEmployee(id: Int)(implicit e: ExecutionContext): Future[Employee] = ??? def getRole(employee :Employee)(implicit e: ExecutionContext): Future[Role] = ??? val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global val bigEmployee: Future[EmployeeWithRole] = getEmployee(100)(ec).flatMap { e => getRole(e)(ec).map { r => EmployeeWithRole(e.id, e.name,r) }(ec) }(ec)
  7. 7. // `ExecutionContext` 
 def getEmployee(id: Int)(implicit e: ExecutionContext): Future[Employee] = ??? def getRole(employee :Employee)(implicit e: ExecutionContext): Future[Role] = ??? val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global val bigEmployee: Future[EmployeeWithRole] = getEmployee(100)(ec).flatMap { e => getRole(e)(ec).map { r => EmployeeWithRole(e.id, e.name,r) }(ec) }(ec)
  8. 8. // `ExecutionContext` 
 def getEmployee(id: Int)(implicit e: ExecutionContext): Future[Employee] = ??? def getRole(employee :Employee)(implicit e: ExecutionContext): Future[Role] = ??? val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global val bigEmployee: Future[EmployeeWithRole] = getEmployee(100)(ec).flatMap { e => getRole(e)(ec).map { r => EmployeeWithRole(e.id, e.name,r) }(ec) }(ec) 🤔🤔🤔
  9. 9. // `ExecutionContext` 
 def getEmployee(id: Int)(implicit e: ExecutionContext): Future[Employee] = ??? def getRole(employee :Employee)(implicit e: ExecutionContext): Future[Role] = ??? implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global val bigEmployee: Future[EmployeeWithRole] = getEmployee(100).flatMap { e => getRole(e).map { r => EmployeeWithRole(e.id, e.name,r) } }
  10. 10. // `ExecutionContext` 
 def getEmployee(id: Int)(implicit e: ExecutionContext): Future[Employee] = ??? def getRole(employee :Employee)(implicit e: ExecutionContext): Future[Role] = ??? implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global val bigEmployee: Future[EmployeeWithRole] = getEmployee(100).flatMap { e => getRole(e).map { r => EmployeeWithRole(e.id, e.name,r) } }
  11. 11. // `ExecutionContext` 
 def getEmployee(id: Int)(implicit e: ExecutionContext): Future[Employee] = ??? def getRole(employee :Employee)(implicit e: ExecutionContext): Future[Role] = ??? implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global val bigEmployee: Future[EmployeeWithRole] = getEmployee(100).flatMap { e => getRole(e).map { r => EmployeeWithRole(e.id, e.name,r) } } 😇😇😇
  12. 12. 😇

×