Howto:Start using vectors and hashes in Nasal: Difference between revisions

Jump to navigation Jump to search
m
Line 522: Line 522:
</syntaxhighlight>
</syntaxhighlight>


This will simply create a function named "new" which accepts an implicit list of arguments (in the implicit "args" vector). The function returns a hash whose parents field is set to the args vector, so this method could even be used for multiple inheritance.
This will simply create a function named "new" which accepts an implicit list of arguments (in the implicit "args" vector). The function returns a hash whose parents field is set to the args vector, so this method could even be used for multiple inheritance. Note that the Position3D hash no longer needs its own constructor, it's really just a simple hash in this case.  




You could even implement an overloaded function that creates arrays of objects.
You could even implement an overloaded function that creates arrays/vectors of objects.


Now, let's imagine you want to add another member function to print a certain field's value, such as "number".  
Now, let's imagine you want to add another member function to print a certain field's value, such as "number".  

Navigation menu