Advertisement
ZivkicaI

AnonymousFunctions

Nov 29th, 2019
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.37 KB | None | 0 0
  1. package part3Udemy
  2.  
  3. object AnonymosObject extends App {
  4.  
  5.       val doubler=new Function1[Int,Int]{
  6.         override def apply(x:Int)=x*2
  7.         //in Scala this above like this  val doubler =(x:Int)=>x*2
  8.         //and this is anonymous function (LAMBDA)
  9.          }
  10.  
  11.       val superAdd=(x:Int) => (y:Int)=>x+y   //anonymous function
  12.       println(superAdd(3)(5))
  13.  
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement