Magik (programming language): Difference between revisions

Content deleted Content added
Pchr8 (talk | contribs)
m Undid revision 938375266 by Pchr8 (talk)
Pchr8 (talk | contribs)
m Standardized spelling of initialise/initialize to British English spelling
Line 68:
}, {:parent_object_a, :parent_object_b})
</pre>
This code fragment will define a new exemplar called <code>my_object</code> that has two slots (or fields) called <code>slot_a</code> (pre-initializedinitialised to 34) and <code>slot_b</code> (pre-initialised to "hello") that inherits from two existing exemplars called <code>parent_object_a</code> and <code>parent_object_b</code>.
 
===Comparison===
Line 94:
_endmethod
</pre>
It is convention to supply two methods <code>new()</code> (to create a new instance) and <code>init()</code> (to initializeinitialise an instance).
<pre>
# New method
Line 101:
_endmethod
 
# InitializeInitialise method.
_private _method person.init(name, age)
# Call the parent implementation.