Call an object method: Difference between revisions
Content added Content deleted
Line 521: | Line 521: | ||
==Icon and {{header|Unicon}}== |
==Icon and {{header|Unicon}}== |
||
Icon does not have objects or methods; they can be implemented on top of other types such as records. |
|||
⚫ | |||
⚫ | |||
<lang unicon>procedure main() |
<lang unicon>procedure main() |
||
⚫ | |||
bar := foo() # create instance |
bar := foo() # create instance |
||
bar.m2() # call method m2 with self=bar |
bar.m2() # call method m2 with self=bar, an implicit first parameter |
||
⚫ | |||
⚫ | |||
⚫ | |||
class foo(cp1,cp2) |
class foo(cp1,cp2) |
||
Line 545: | Line 547: | ||
L := [cp1] |
L := [cp1] |
||
end</lang> |
end</lang> |
||
Note: Icon cannot translate code with objects. It may be possible for Icon to translate code preprocessed by Unicon if no other Unicon extensions are used. |
|||
=={{header|J}}== |
=={{header|J}}== |