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

Jump to navigation Jump to search
+- first section
(Use Nasal syntax-highlighting)
(+- first section)
Line 1: Line 1:
{{Nasal Navigation}}
{{Nasal Navigation}}


Objective: Learn more about vectors and hashes to see how you can simplify and generalize your code easily.
Here we look into how to '''start using vectors and hashes in Nasal''' to simplify and generalize code.  Vectors and hashes are two data structures that [[Nasal]] uses to store data.  Vectors are in some other programming languages called for example lists or one-dimensional arrays, and hashes is similar to C's structs.
 
In many cases repetitive code can be generalized and rewritten into vectors, hashes or helper functions using them.  Some of the advantages with rewriting repetitive code this way is that it helps maintenance by requiring less typing when modifying and/or when fixing bugs.
 
In addition to storing data hashes can "store" functions and be used as object classes.  Object classes can be created by adding a function into a hash, that will create a new hash when called, a so called ''creator'' (sometimes abbreviated to ''c'tor'') usually named <code>'''new'''()</code>.


== Learn more about vectors ==
== Learn more about vectors ==

Navigation menu