Content deleted Content added
Extension methods in Java |
|||
Line 13:
In C# they're implemented as static methods in static classes, with the first argument being of extended class and preceded by "<code>this</code>" keyword.
In Java you add extension methods via [http://manifold.systems/ Manifold], a jar file you add to your project's classpath. Similar to C# a Java extension method is declared static in an [http://manifold.systems/docs.html#extension-classes @Extension] class where the first argument has the same type as the extended class and is annotated with <code>@This</code>.
In Smalltalk, any code can add a method to any class at any time, by sending a method creation message (such as <code>methodsFor:</code>) to the class the user wants to extend. The Smalltalk method category is conventionally named after the package that provides the extension, surrounded by asterisks. For example, when Etoys application code extends classes in the core library, the added methods are put in the <code>*etoys*</code> category.
Line 219 ⟶ 221:
*[http://www.drdobbs.com/cpp/uniform-function-call-syntax/232700394 Uniform function call syntax]
*[http://csharp-software-development.blogspot.co.uk/ Extension methods in C#]
*[http://manifold.systems/docs.html#the-extension-manifold Extension Methods in Java]
[[Category:Method (computer programming)]]
|