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

Jump to navigation Jump to search
m
Undo revision 40254 by Hooray (talk)
mNo edit summary
m (Undo revision 40254 by Hooray (talk))
Line 98: Line 98:
* bearing
* bearing


Now, to access any of these fields, we would use the "dot notation" by first specifying the name of the enclosing context (which is really just a fancy word for the name of the hash) and the name of the field we are interested in:
Now, to access any of these fields, we would use the "dot notation" by first specifying the name of the enclosing context (which is really just a fancy word for the name of the hash) and the name of the field we are interested in. You could read this as: LOCATION.FIELD (i.e. get FIELD out of location).


<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
Line 110: Line 110:
print ( waypoint.bearing );
print ( waypoint.bearing );
</syntaxhighlight>
</syntaxhighlight>
So, the hash represents the surrounding environment (i.e. context or "namespace") in which these symbols are valid. For more information on namespaces, please see [[Namespaces and Methods]].


Now, to make this is a little more interesting and to show what's happening, we are going to change the value of each field:
Now, to make this is a little more interesting and to show what's happening, we are going to change the value of each field:

Navigation menu