Content deleted Content added
Artoria2e5 (talk | contribs) →KornShell 93, and compliant shells: bash4 can do typeset |
Artoria2e5 (talk | contribs) →Language support: no leading 1 space in syntaxhighlight |
||
Line 177:
Initializing an empty dictionary and adding items in [[Cobra (programming language)|Cobra]]:
{{sxhl|2=python|1=<nowiki/>
}}
Alternatively, a dictionary can be initialized with all items during construction:
{{sxhl|2=python|1=<nowiki/>
}}
The dictionary can be enumerated by a for-loop, but there is no guaranteed order:
{{sxhl|2=python|1=<nowiki/>
}}
Line 723:
Declare dictionary:
<syntaxhighlight lang="julia">
</syntaxhighlight>
Access element:
<syntaxhighlight lang="julia">
</syntaxhighlight>
Add element:
<syntaxhighlight lang="julia">
</syntaxhighlight>
Delete element:
<syntaxhighlight lang="julia">
</syntaxhighlight>
Get keys and values as [[Iterator#Implicit iterators|iterables]]:
<syntaxhighlight lang="julia">
</syntaxhighlight>
===KornShell 93, and compliant shells===
Line 1,069 ⟶ 1,074:
<syntaxhighlight lang="mathematica">
</syntaxhighlight>
Line 1,077 ⟶ 1,082:
<syntaxhighlight lang="mathematica">
</syntaxhighlight>
Line 1,083 ⟶ 1,088:
<syntaxhighlight lang="mathematica">
</syntaxhighlight>
Line 1,220 ⟶ 1,225:
<syntaxhighlight lang=Java>
String[String] phoneBook = {
"Sally Smart" -> "555-9999",
"John Doe" -> "555-1212",
"J. Random Hacker" -> "553-1337"
};
Line 1,229 ⟶ 1,234:
// iterate over the values
for (String number : phoneBook) {
System.out.println(number);
}
Line 1,236 ⟶ 1,241:
// iterate over the keys
for (String name : phoneBook.keys) {
System.out.println(name + " -> " + phoneBook[name]);
}
// phoneBook[name] access a value by a key (it looks like java array access)
Line 1,247 ⟶ 1,252:
<syntaxhighlight lang=Java>
</syntaxhighlight>
|