Call an object method: Difference between revisions
Content added Content deleted
(add supercollider example) |
(added MiniScript example) |
||
Line 1,189: | Line 1,189: | ||
<lang Maple># Instance |
<lang Maple># Instance |
||
Method( obj, other, arg );</lang> |
Method( obj, other, arg );</lang> |
||
=={{header|MiniScript}}== |
|||
MiniScript uses prototype-based inheritance, so the only difference between a static method and an instance method is in whether it uses the <code>self</code> pseudo-keyword. |
|||
<lang MiniScript>Dog = {} |
|||
Dog.name = "" |
|||
Dog.help = function() |
|||
print "This class represents dogs." |
|||
end function |
|||
Dog.speak = function() |
|||
print self.name + " says Woof!" |
|||
end function |
|||
fido = new Dog |
|||
fido.name = "Fido" |
|||
Dog.help // calling a "class method" |
|||
fido.speak // calling an "instance method"</lang> |
|||
{{out}} |
|||
<pre>This class represents dogs. |
|||
Fido says Woof!</pre> |
|||
=={{header|Nemerle}}== |
=={{header|Nemerle}}== |