Extension method: Difference between revisions

Content deleted Content added
No edit summary
Line 10:
 
==Support in programming languages==
Extension methods are features of numerous languages including [[C Sharp (programming language)|C#]], [[Java (programming language)|Java]] via [http://manifold.systems/docs.html#the-extension-manifold Manifold], [[Gosu (programming language)|Gosu]], [[Javascript]], [[Oxygene (programming language)|Oxygene]], [[Ruby (programming language)|Ruby]], [[Smalltalk]], [[Kotlin (programming language)|Kotlin]] and, [[VB.NET|Visual Basic.NET]] and [[Xojo]]. In dynamic languages like [[Python (programming language)|Python]], the concept of an extension method is unnecessary because classes can be extended without any special syntax (an approach known as "monkey-patching", employed in libraries such as [[gevent]]).
 
In VB.NET and Oxygene, they are recognized by the presence of the "<code>extension</code>" keyword or attribute. In Xojo the "<code>Extends</code>" keyword is used with global methods.
 
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.