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:

Could not embed GitHub Gist 3838785: API rate limit exceeded for 81.169.144.135. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)

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

Leave a Reply

  • (will not be published)