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

Content deleted Content added
PHP: copy editing, linking, and referencing
Pike: copy editing, etc.
Line 1,383:
Associative arrays that can use objects as keys, instead of strings and integers, can be implemented with the <code>SplObjectStorage</code> class from the Standard PHP Library (SPL).<ref>http://php.net/SplObjectStorage</ref>
 
=== [[Pike (programming language)|Pike]] ===
[[Pike (programming language)|Pike]] has built-in support for Associativeassociative Arraysarrays, which are referred to as mappings. Mappings are created as follows:
 
<syntaxhighlight lang=Pike>
Line 1,396:
Accessing and testing for presence in mappings is done using the indexing operator. So <code>phonebook["Sally Smart"]</code> would return the string <code>"555-9999"</code>, and <code>phonebook["John Smith"]</code> would return 0.
 
Iterating through a mapping can be done using either <code>foreach</code>:
 
<syntaxhighlight lang=pike>
Line 1,414:
</syntaxhighlight>
 
Elements of a mapping can be removed using <code>m_delete</code>, which returns the value of the removed index:
 
<syntaxhighlight lang=pike>