File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 13
13
yield map
14
14
map
15
15
16
+ :it "knows the size of the map"
17
+ map = @build_map -> (map |
18
+ map["foo"] = 11
19
+ map["bar"] = 22
20
+ map["baz"] = 33
21
+ )
22
+ assert: map.size == 3
23
+ assert: map.is_empty.is_false
24
+ assert: map.is_not_empty
25
+
26
+ map = @build_map -> (map | None)
27
+ assert: map.size == 0
28
+ assert: map.is_empty
29
+ assert: map.is_not_empty.is_false
30
+
16
31
:it "yields each key and each value (separately)"
17
32
map = @build_map -> (map |
18
33
map["foo"] = 11
Original file line number Diff line number Diff line change 6
6
:: of the interface can get them "for free" by inheriting the trait.
7
7
:trait box Map.Readable(K, V)
8
8
:fun size USize
9
+
9
10
:fun has_key(key K) Bool
10
11
:fun "[]!"(key K) @->(V'aliased)
11
12
13
+ :: Return true if the map is empty (i.e. has no key/value pairs).
14
+ :fun is_empty Bool: @size == 0
15
+
16
+ :: Return true if the map is non-empty (i.e. has at lease one key/value pair).
17
+ :fun is_not_empty Bool: @size != 0
18
+
12
19
:: Yield each key and value in the map.
13
20
:fun each None
14
21
:yields (@->(K'aliased), @->(V'aliased)) for None
You can’t perform that action at this time.
0 commit comments