Scala extractors provide a nice way to use pattern matching on common Java objects. In this post I'm going to show a simple use of extractors with Java reflection objects.
More detailed information about Scala extractors can be found in the main website, in the Scala Language Specification section 8.1.7 and in the Matching Object With Patterns paper.
An extractor object can be used to extract simple values from Java objects. For example, the following code defines a extractor object that returns the name of a java.lang.Class.
links for 2011-08-13