Skip to content

Commit

Permalink
Update README to mention subscript access on collections.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpolzin committed Jan 13, 2019
1 parent e03e896 commit 77f45b8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ let animals: [Poly3<Dog, Cat, Rat>] = [
]
```

To access all animals of a certain type, you can use subscripting like:
```swift
let dogs = animals[Dog.self]
let cats = animals[Cat.self]
let rats = animals[Rat.self]
```

You can get the `Dog`, `Cat`, or `Rat` value back out again, but you won't get any guarantees of which Type is being stored in a given `Poly`:
```swift
let animal = Poly3<Dog, Cat, Rat>(Dog())
Expand Down

0 comments on commit 77f45b8

Please sign in to comment.