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

Content deleted Content added
m Ruby: ed
Ruby: ed
Line 829:
 
<source lang="ruby">
### iterate over keys and values
phonebook.each {|key, value| puts key + " => " + value}
</source>
 
### iterate keys only
Additionally, each key may be shown individually:
 
<source lang="ruby">
phonebook.each_key {|key| puts key}
</source>
 
Each value may, of course, also be shown:
 
### iterate values only
<source lang="ruby">
phonebook.each_value {|value| puts value}
</source>