Call an object method: Difference between revisions

m (→‎{{header|Ruby}}: Edit for style. Also avoid Class#method.)
Line 199:
<lang PicoLisp>(foo> MyClass)
(foo> MyObject)</lang>
=={{header|Pike}}==
Pike does not have static methods. (the <code>static</code> modifier in Pike is similar to <code>protected</code> in C++).
 
regular methods can be called in these ways:
<lang Pike>obj->method();
obj["method"]();
call_function(obj->method);
call_function(obj["method"]);</lang>
<code>call_function()</code> is rarely used anymore.
 
because <code>()</code> is actually an operator that is applied to a function reference, the following is also possible:
<lang Pike>function func = obj->method;
func();</lang>
as alternative to static function, modules are used. a module is essentially a static class. a function in a module can be called like this:
<lang Pike>module.func();
module["func"]();</lang>
it should be noted that <code>module.func</code> is resolved at compile time while <code>module["func"]</code> is resolved at runtime.
 
=={{header|Python}}==
Anonymous user