Jump to content

Call an object method: Difference between revisions

added smalltalk
(added go)
(added smalltalk)
Line 123:
 
// Instance
[myInstance method:someParameter];</lang>
 
// Method with multiple arguments
[myInstance methodWithRed:arg1 green:arg2 blue:arg3];
 
// Method with no arguments
[myInstance method];</lang>
 
=={{header|Perl}}==
Line 206 ⟶ 212:
# Calling a method with no parameters
myInstance.anotherMethod</lang>
 
=={{header|Smalltalk}}==
In Smalltalk, calling an instance method is sending a message to an instance, and calling a class method is sending a message to a class object. Class methods are inherited through inheritance of classes. All messages (whether sent to a normal object or class object) are resolved dynamically at runtime, hence there are no "static" methods.
<lang smalltalk>" Class "
MyClass method:someParameter .
" or equivalently "
foo := MyClass .
foo method:someParameter .
 
" Instance "
myInstance method:someParameter .
 
" Method with multiple arguments "
myInstance methodWithRed:arg1 green:arg2 blue:arg3 .
 
" Method with no arguments "
myInstance method .
 
" Operator method "
myInstance + somethingElse .</lang>
 
=={{header|Tcl}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.