Comparison of programming languages (associative array): Difference between revisions

Content deleted Content added
Python (programming language)|Python: correcting section heading and linking
Red: copy editing
Line 1,562:
The dictionary keys must be of an [[Immutable object|immutable]] data type. In Python, strings are immutable due to their method of implementation.
 
=== [[Red (programming language)|Red]] ===
In [[Red (programming language)|Red]] the built-in <code>map!</code><ref>{{cite web|url=https://doc.red-lang.org/en/datatypes/map.html|title=Map! datatype|website=doc.red-lang.org}}</ref> datatype provides an associative array mappingthat maps values of word, string, and scalar key types to values of any type. A hash table is used internally for lookup of keys.
 
A map can be written as a literal, such likeas <code>#(key1 value1 key2 value2 ...)</code>, or can be created using <code>make map! [key1 value1 key2 value2 ...]</code>. For example:
 
<syntaxhighlight lang=Red>