Anonymous user
Associative array: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 8:
For example in [[awk]] and [[Perl]] the keys are evaluated (as “scalars” in Perl terminology). Thus the the keys <tt>"1"</tt> (a string) and <tt>1</tt> (an integer) and <tt>1.0</tt> (a real or floating point number) would all evaluate into equivalent keys. By contrast these would each be distinct in Python. In a [[Python]] dictionary any immutable object (strings, integer, floats) and any object/class which implements the <tt>__hash__</tt> special method can be used as a key. Values can be references to any objects (including functions, classes, class methods which are all "first class objects" in that language). In [[Lua]], a table is a complex data structure which can be used to implement arrays, objects and associative arrays (integer key values are implicitly treated like indices into a virtual array, those with values that reference functions are methods, those which reference other types of objects are attributes or members).
Associative arrays are used as the underlying data structure for objects in a number of languages. Python objects normally have a visible <tt>__dict__</tt> attribute by which its methods and other attributes can be accessed indirectly
==References==
|