Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
An extractor is an object with an unapply method. You can think of the unapply method as being the opposite of the apply method of a companion object. An apply method takes construction parameters and turns them into an object. An unapply method takes an object and extracts values from it—usually the values from which the object was constructed.
Consider the Fraction class from the preceding section. The apply method makes a fraction from a numerator and denominator. An unapply method retrieves the numerator and denominator. You can use it in a variable definition