Skip to content

Commit e7bce0d

Browse files
author
Simon Whitaker
committed
Add more toys to the playground
1 parent b4533bf commit e7bce0d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Multiset/Multiset.playground/Contents.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,18 @@ set2.add("Foo")
2525
set2.isSubSet(of: set) // true
2626
set.isSubSet(of: set2) // false
2727

28+
// Convenience constructor: pass a Collection of Hashables to the constructor
2829
var cacti = Multiset<Character>("cacti")
30+
cacti.allItems
2931
var tactical = Multiset<Character>("tactical")
3032
cacti.isSubSet(of: tactical) // true
3133
tactical.isSubSet(of: cacti) // false
34+
35+
// Test ExpressibleByArrayLiteral protocol
36+
let set3: Multiset<String> = ["foo", "bar"]
37+
set3.count(for: "foo")
38+
39+
// Test Equatable protocol
40+
let set4 = Multiset<String>(set3.allItems)
41+
set4 == set3 // true
42+
set4 == set // false

0 commit comments

Comments
 (0)