The binary subtraction or "minus" operator - subtracts the value of the right operand from the value of the left operand and returns the resulting value.
This operator performs mathematical subtraction if both operands contain decimal or integer values. The result will be a decimal if either operand is a decimal value.
This operator performs string removal if the left-hand operand is a string. The result is the left operand with the first occurrence of the string value of the right operand removed.
This operator also comes in a negation or "unary minus" method variant. This method variant is differentiated by not accept a parameter. I.e. it does not accept the parameter which would normally represent the right-hand operand. Negation generally only applies to integers or decimals, although any type may implement this method if needed.
The - method to be called is always the one belonging to the left-hand operand. When creating a custom implementation of either the binary subtraction or unary minus operator, it is important to not modify either operand. The - operator should always return a newly created value.
Also provided is the stand-alone - method which can be accessed using the escape method operator. This permits subtraction operations to be passed as values and later invoked for whatever reason. This method eventually calls the - operator on the left-hand operand.
Often, the - method is only supported with a particular type of left-hand operand. If the - operator is not supported for the given left and right operand type combination, the standard "definition not found" failure will occur.
Note that directly calling the - operator method (e.g. 'hi'->-('bye')) is not permitted. However, it is permitted to access an object's - method using the escape method operator (e.g. 'hi'->\-).
left_parameter - right_parameter local(result = left_parameter - right_parameter) #result = left_parameter - right_parameter -value
No examples found
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.