Extension method: Difference between revisions

Content deleted Content added
m Added Project Lombok as implementation possibility for Java
adding a reference
Line 20:
In Ruby, like Smalltalk, there is no special language feature for extension, as Ruby allows classes to be re-opened at any time with the <code>class</code> keyword, in this case, to add new methods. The Ruby community often describes an extension method as a kind of [[monkey patch]]. There is also a newer feature for adding safe/local extensions to the objects, called [https://docs.ruby-lang.org/en/2.5.0/syntax/refinements_rdoc.html Refinements], but it is known to be less used.
 
In Swift, the <code>extension</code> keyword marks a class-like construct that allows the addition of methods, constructors, and fields to an existing class, including the ability to implement a new interface/protocol to the existing class.<ref>{{Cite web |title=Extensions — The Swift Programming Language (Swift 5.7) |url=https://docs.swift.org/swift-book/LanguageGuide/Extensions.html |access-date=2022-06-12 |website=docs.swift.org}}</ref>
 
==Extension methods as enabling feature==