File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 yield map
1414 map
1515
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+
1631 :it "yields each key and each value (separately)"
1732 map = @build_map -> (map |
1833 map["foo"] = 11
Original file line number Diff line number Diff line change 66:: of the interface can get them "for free" by inheriting the trait.
77:trait box Map.Readable(K, V)
88 :fun size USize
9+
910 :fun has_key(key K) Bool
1011 :fun "[]!"(key K) @->(V'aliased)
1112
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+
1219 :: Yield each key and value in the map.
1320 :fun each None
1421 :yields (@->(K'aliased), @->(V'aliased)) for None
You can’t perform that action at this time.
0 commit comments