Skip to content

Commit

Permalink
Merge pull request #54 from alranel/array-contains
Browse files Browse the repository at this point in the history
Support Contains() for arrays too
  • Loading branch information
thoas committed Mar 28, 2019
2 parents 4a778ad + 525830b commit b699652
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion presence.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func Contains(in interface{}, elem interface{}) bool {
return true
}
}
case reflect.Slice:
case reflect.Slice, reflect.Array:
for i := 0; i < inValue.Len(); i++ {
if equal(inValue.Index(i).Interface(), elem) {
return true
Expand Down
1 change: 1 addition & 0 deletions presence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestContains(t *testing.T) {
is := assert.New(t)

is.True(Contains([]string{"foo", "bar"}, "bar"))
is.True(Contains([...]string{"foo", "bar"}, "bar"))

is.True(Contains(results, f))
is.False(Contains(results, nil))
Expand Down

0 comments on commit b699652

Please sign in to comment.