Skip to content

Commit

Permalink
Merge pull request #5 from tw1nk/master
Browse files Browse the repository at this point in the history
Add Keys function to types.Dict
  • Loading branch information
matteo-grella authored Feb 22, 2023
2 parents 3579632 + f85a1e5 commit 1b56f50
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions types/dict.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,13 @@ func (d *Dict) MustGet(key interface{}) interface{} {
func (d *Dict) Len() int {
return len(*d)
}

// Keys returns the keys of the dict
func (d *Dict) Keys() []interface{} {
out := make([]interface{}, len(*d))
for i, entry := range *d {
out[i] = entry.Key
}

return out
}

0 comments on commit 1b56f50

Please sign in to comment.