Closed notEpsilon closed 1 year ago
old
func (s *threadUnsafeSet[T]) Pop() (v T, ok bool) { for item := range *s { delete(*s, item) return item, true } return }
in my opinion, the last return badly impacts readability.
return
refactored
func (s *threadUnsafeSet[T]) Pop() (T, bool) { for item := range *s { delete(*s, item) return item, true } return *new(T), false }
$ go test ./... -cover -race ok github.com/deckarep/golang-set/v2 79.012s coverage: 94.8% of statements
old
in my opinion, the last
return
badly impacts readability.refactored
test results