Posted by & filed under Coding.

Extending the functionality of classes is trivial: simply use inheritance and add new methods.

There are cases where extending classes by inheritance is not practicable, e.g. given final classes like java.lang.String.

Another simple way of extending the functionality of classes is applying methods defined somewhere else. Modern languages like Xtend and Scala provide convenient syntax for this:

One Response to “Extension Methods in Java, Xtend & Scala”

Leave a Reply

  • (will not be published)