Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,5 @@
|
|||
Map<String, Int> map = new HashMap();
|
||||
map["foo"] = 5; // or: map.put("foo", 5)
|
||||
map["bar"] = 10;
|
||||
map["baz"] = 15;
|
||||
map["foo"] = 6; // replaces previous value of 5
|
||||
|
|
@ -0,0 +1 @@
|
|||
Map<String, Int> map = ["foo"=6, "bar"=10, "baz"=15];
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
Int? mightBeNull = map["foo"];
|
||||
Int neverNull = map.getOrDefault("foo", 0);
|
||||
if (Int n := map.get("foo")) {
|
||||
// if "foo" is in the map, then the variable "n" is set to its value
|
||||
} else {
|
||||
// if "foo" is not in the map, then the variable "n" is not defined
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
for (String key : map) {
|
||||
// the variable "key" is defined here
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
for (Int value : map.values) {
|
||||
// the variable "value" is defined here
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
for ((String key, Int value) : map) {
|
||||
// the variables "key" and "value" are defined here
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue