AllSame
Returns true
if all elements in the collection have the same value, false
otherwise.
- Use
reflect.ValueOf()
to get the array or slice,Value.Index()
andValue.Interface()
to get the first value. - Use a
for
loop withValue.Len()
andValue.Index()
to iterate over each element and compare it to the search value. - Return
false
if a non-matching value is found,true
otherwise.