Professional Documents
Culture Documents
Bala's Blog: Java, Big Data and Technology
Bala's Blog: Java, Big Data and Technology
POSTED BY
BALACHANDAR
POSTED ON
GENERAL, SCALA
COMMENTS
LEAVE A COMMENT
An Extractor object is an object with an unapply method which takes an object and tries to give back its
arguments.
As we all know that apply method of an Object takes arguments and creates an object and the unapply
method will do the reverse.
customer match {
case Customer(name) => println(s"FirstName is:$name")
case _ => println("Could not extract Name")
}
}
}
In the above code, Customer is an object and the apply method takes first and last names and combine
those names with a comma symbol and the unapply method takes the name and split it and then return
the first name as an output.
FirstName is:Balachandar
Scala (h ps://dkbalachandar.wordpress.com/tag/scala/)