Feature Overview
This feature enables patching methods to an existing type.
This feature enables patching methods to an existing type.
None.
public class PatchDemo {
@patch(String)
public static String prefix(String s, String prefix) {
return prefix + s;
}
public static void main() {
String result = 'abc'.prefix('_');
}
}
public class PatchDemo {
public static String prefix(String s, String prefix) {
return prefix + s;
}
public static void main() {
String result = PatchDemo.prefix('abc', '_');
}
}
The method annotated with @patch
is a patching method.
Patching methods should be public/global static, and they should declare the type to patch on. Besides, the first parameter should accept the instance of the patch class.
Contribute on Github! Edit this section.