What is the difference between apply and unapply methods in scala?



What is the difference between apply and unapply methods in scala?..

Answer / Nitin Gupta

The apply method is used to create a new instance of a case class, while the unapply method is used to deconstruct an instance of a case class. The apply method takes arguments and creates a new object, while the unapply method breaks down an existing object into its constituent parts.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Scala Interview Questions

What do you understand by an implicit parameter in scala ?

1 Answers  


What is recursion tail in scala?

1 Answers  


How to define Factory methods using object keyword in Scala? What is the use of defining Factory methods in object?

1 Answers  


What are the advantages of scala over java (java 8)?

1 Answers  


How do we declare a private Primary Constructor in Scala? How do we make a call to a private Primary Constructor in Scala?

1 Answers  


What is the Main drawback of Scala Language?

1 Answers  


Mention the advantages of scala?

1 Answers  


How do we make a call to a private primary constructor in scala?

1 Answers  


what are the features of scala?

1 Answers  


Why do we need app in scala?

1 Answers  


What are the advantages of case class?

1 Answers  


What is unapply method in scala?

1 Answers  


Categories