Feature Overview
This feature converts a static method to an operator.
This feature converts a static method to an operator.
None
public class OperatorDemo {
@operator
public static Integer add(Integer a, Integer b) {
return a + b;
}
public static void main() {
Object a = 1;
Object b = 2;
System.debug(a add b);
}
}
public class OperatorDemo {
public static Integer add(Integer a, Integer b) {
return a + b;
}
public static void main() {
Object a = 1;
Object b = 2;
System.debug((Integer)OperatorDemo.add((Integer)a, (Integer)b));
}
}
@operator
can only be used on public/global static methods with two parameters and one return value.
Some variations are:
Example | Description |
---|---|
@operator | Convert the method to an operator |
@operator('name') | Convert the method to an operator with the given name |
@operator(name='name') | Convert the method to an operator with the given name |
Contribute on Github! Edit this section.