|
|
|
Call and SpliceIn this section we explain two operators that are used in connection with calls to methods: the method-call operator and the splice operator. A method call, which we have seen many examples of, is actually a use of the method-call operator. It is written with a pair of parentheses according to this template: method-expression ( argument-list )First the method-expression is calculated, to find out which method to call. The method-expression is often a single identifier, such as write, but can be more complicated. Then all the expressions in the comma-separated argument-list are calculated. Finally, the method is executed, with the argument values as parameters. Some notes about the method-call operator:
The splice operator, written with a commercial-at sign (@), lets us use an array as an argument list. For example, array a = ({ 17, -0.3, "foo" }); koogle(@a); is equivalent to koogle(17, -0.3, "foo"); |
|||