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

Content deleted Content added
added scala
Fixed D examples so that it compiles with DMD2
Line 194:
=== D ===
[[D programming language|D]] offers direct support for associative arrays
in the core language - they are implemented as a chaining hash table with binary trees<ref>{{Cite web|url=http://www.digitalmars.com/webnewsd/newsgroups2.php?art_group=digitalmars0/hash-map.D&article_id=30153html |title=DAssociative NewsletterArrays |accessdate=20082011-0602-1501 |work= |date= }}</ref>. The equivalent example would be:
 
<source lang="d">
int main() {
charstring[][char[] string ] phone_book;
phone_book["Sally Smart"] = "555-9999";
phone_book["John Doe"] = "555-1212";
Line 213:
<source lang="d">
foreach (key, value; phone_book) {
writefln writeln("Number for $name" ~ key ~ ": $number\n", key,~ value ~ "\n" );
}
</source>