Repository: elliotchance/pie (go)
Issue: Rename Only -> Select
`Select` is more inline with other implementations. Also, the opposite function `Without` should be `Unselect`? 
Pull request description: Rename Only/Without to Select/Unselect. Fixes #36


<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/elliotchance/pie/50)
<!-- Reviewable:end -->


Patch:
diff --git a/README.md b/README.md
index 1e39995..75ba173 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ import (
 
 func main() {
     name := pie.Strings{"Bob", "Sally", "John", "Jane"}.
-        Without(func (name string) {
+        Unselect(func (name string) {
             return strings.HasPrefix(name, "J")
         }).
         Transform(strings.ToUpper).
@@ -81,7 +81,7 @@ cars := Cars{
     {"Jane", "red"},
 }
 
-redCars := cars.Only(func(car Car) bool {
+redCars := cars.Select(func(car Car) bool {
     return car.Color == "red"
 })
 
@@ -91,7 +91,7 @@ redCars := cars.Only(func(car Car) bool {
 Or, more complex operations can be chained:
 
 ```go
-cars.Without(func (car Car) {
+cars.Unselect(func (car Car) {
         return strings.HasPrefix(car.Name, "J")
     }).
     Transform(func (car Car) Car {
@@ -111,10 +111,10 @@ creates a lot of unused code. You can limit the functions generated by chaining
 the function names with a dot syntax, like:
 
 ```go
-//go:generate myInts.Average.Sum myStrings.Only
+//go:generate myInts.Average.Sum myStrings.Select
 ```
 
-This will only generate `myInts.Average`, `myInts.Sum` and `myStrings.Only`.
+This will only generate `myInts.Average`, `myInts.Sum` and `myStrings.Select`.
 
 # Functions
 
@@ -132,13 +132,13 @@ This will only generate `myInts.Average`, `myInts.Sum` and `myStrings.Only`.
 | `Len`        | ✓      | ✓      | ✓      | 1        | Number of elements. |
 | `Max`        | ✓      | ✓      |        | n        | The maximum value, or a zeroes value. |
 | `Min`        | ✓      | ✓      |        | n        | The minimum value, or a zeroed value. |
-| `Only`       | ✓      | ✓      | ✓      | n        | A new slice containing only the elements that returned true from the condition. |
 | `Reverse`    | ✓      | ✓      | ✓      | n        | Reverse elements. |
+| `Select`     | ✓      | ✓      | ✓      | n        | A new slice containing only the elements that returned true from the condition. |
 | `Sort`       | ✓      | ✓      |        | n⋅log(n) | Return a new sorted slice. |
 | `Sum`        |        | ✓      |        | n        | Sum (total) of all elements. |
 | `Transform`  | ✓      | ✓      | ✓      | n        | A new slice where each element has been transformed. |
 | `Unique`     | ✓      | ✓      |        | n⋅log(n) | Return a new slice with only unique elements. |
-| `Without`    | ✓      | ✓      | ✓      | n        | A new slice containing only the elements that returned false from the condition. |
+| `Unselect`   | ✓      | ✓      | ✓      | n        | A new slice containing only the elements that returned false from the condition. |
 
 # FAQ
 
diff --git a/pie/carpointers_pie.go b/pie/carpointers_pie.go
index 2594c1b..f813aa1 100755
--- a/pie/carpointers_pie.go
+++ b/pie/carpointers_pie.go
@@ -14,7 +14,7 @@ func (ss carPointers) Contains(lookingFor *car) bool {
 	return false
 }
 
-func (ss carPointers) Only(condition func(*car) bool) (ss2 carPointers) {
+func (ss carPointers) Select(condition func(*car) bool) (ss2 carPointers) {
 	for _, s := range ss {
 		if condition(s) {
 			ss2 = append(ss2, s)
@@ -24,7 +24,7 @@ func (ss carPointers) Only(condition func(*car) bool) (ss2 carPointers) {
 	return
 }
 
-func (ss carPointers) Without(condition func(*car) bool) (ss2 carPointers) {
+func (ss carPointers) Unselect(condition func(*car) bool) (ss2 carPointers) {
 	for _, s := range ss {
 		if !condition(s) {
 			ss2 = append(ss2, s)
diff --git a/pie/cars_pie.go b/pie/cars_pie.go
index f0257a7..018afb9 100755
--- a/pie/cars_pie.go
+++ b/pie/cars_pie.go
@@ -14,7 +14,7 @@ func (ss cars) Contains(lookingFor car) bool {
 	return false
 }
 
-func (ss cars) Only(condition func(car) bool) (ss2 cars) {
+func (ss cars) Select(condition func(car) bool) (ss2 cars) {
 	for _, s := range ss {
 		if condition(s) {
 			ss2 = append(ss2, s)
@@ -24,7 +24,7 @@ func (ss cars) Only(condition func(car) bool) (ss2 cars) {
 	return
 }
 
-func (ss cars) Without(condition func(car) bool) (ss2 cars) {
+func (ss cars) Unselect(condition func(car) bool) (ss2 cars) {
 	for _, s := range ss {
 		if !condition(s) {
 			ss2 = append(ss2, s)
diff --git a/pie/float64s_pie.go b/pie/float64s_pie.go
index ea9b1d4..c7f7261 100755
--- a/pie/float64s_pie.go
+++ b/pie/float64s_pie.go
@@ -15,7 +15,7 @@ func (ss Float64s) Contains(lookingFor float64) bool {
 	return false
 }
 
-func (ss Float64s) Only(condition func(float64) bool) (ss2 Float64s) {
+func (ss Float64s) Select(condition func(float64) bool) (ss2 Float64s) {
 	for _, s := range ss {
 		if condition(s) {
 			ss2 = append(ss2, s)
@@ -25,7 +25,7 @@ func (ss Float64s) Only(condition func(float64) bool) (ss2 Float64s) {
 	return
 }
 
-func (ss Float64s) Without(condition func(float64) bool) (ss2 Float64s) {
+func (ss Float64s) Unselect(condition func(float64) bool) (ss2 Float64s) {
 	for _, s := range ss {
 		if !condition(s) {
 			ss2 = append(ss2, s)
diff --git a/pie/ints_pie.go b/pie/ints_pie.go
index 9db2dc1..6a4db4f 100755
--- a/pie/ints_pie.go
+++ b/pie/ints_pie.go
@@ -15,7 +15,7 @@ func (ss Ints) Contains(lookingFor int) bool {
 	return false
 }
 
-func (ss Ints) Only(condition func(int) bool) (ss2 Ints) {
+func (ss Ints) Select(condition func(int) bool) (ss2 Ints) {
 	for _, s := range ss {
 		if condition(s) {
 			ss2 = append(ss2, s)
@@ -25,7 +25,7 @@ func (ss Ints) Only(condition func(int) bool) (ss2 Ints) {
 	return
 }
 
-func (ss Ints) Without(condition func(int) bool) (ss2 Ints) {
+func (ss Ints) Unselect(condition func(int) bool) (ss2 Ints) {
 	for _, s := range ss {
 		if !condition(s) {
 			ss2 = append(ss2, s)
diff --git a/pie/strings_pie.go b/pie/strings_pie.go
index 0b6fc9d..9f6065d 100755
--- a/pie/strings_pie.go
+++ b/pie/strings_pie.go
@@ -15,7 +15,7 @@ func (ss Strings) Contains(lookingFor string) bool {
 	return false
 }
 
-func (ss Strings) Only(condition func(string) bool) (ss2 Strings) {
+func (ss Strings) Select(condition func(string) bool) (ss2 Strings) {
 	for _, s := range ss {
 		if condition(s) {
 			ss2 = append(ss2, s)
@@ -25,7 +25,7 @@ func (ss Strings) Only(condition func(string) bool) (ss2 Strings) {
 	return
 }
 
-func (ss Strings) Without(condition func(string) bool) (ss2 Strings) {
+func (ss Strings) Unselect(condition func(string) bool) (ss2 Strings) {
 	for _, s := range ss {
 		if !condition(s) {
 			ss2 = append(ss2, s)
diff --git a/pie_all.go b/pie_all.go
index a1c0ad7..015586e 100644
--- a/pie_all.go
+++ b/pie_all.go
@@ -19,11 +19,11 @@ func (ss SliceType) Contains(lookingFor ElementType) bool {
 	return false
 }
 
-// Only will return a new slice containing only the elements that return
+// Select will return a new slice containing only the elements that return
 // true from the condition. The returned slice may contain zero elements (nil).
 //
-// SliceTypeWithout works in the opposite way as SliceTypeOnly.
-func (ss SliceType) Only(condition func(ElementType) bool) (ss2 SliceType) {
+// Unselect works in the opposite way as Select.
+func (ss SliceType) Select(condition func(ElementType) bool) (ss2 SliceType) {
 	for _, s := range ss {
 		if condition(s) {
 			ss2 = append(ss2, s)
@@ -33,10 +33,10 @@ func (ss SliceType) Only(condition func(ElementType) bool) (ss2 SliceType) {
 	return
 }
 
-// Without works the same as Only, with a negated condition. That is, it will
+// Unselect works the same as Select, with a negated condition. That is, it will
 // return a new slice only containing the elements that returned false from the
 // condition. The returned slice may contain zero elements (nil).
-func (ss SliceType) Without(condition func(ElementType) bool) (ss2 SliceType) {
+func (ss SliceType) Unselect(condition func(ElementType) bool) (ss2 SliceType) {
 	for _, s := range ss {
 		if !condition(s) {
 			ss2 = append(ss2, s)
diff --git a/template.go b/template.go
index c93b670..5f06e31 100644
--- a/template.go
+++ b/template.go
@@ -22,11 +22,11 @@ func (ss SliceType) Contains(lookingFor ElementType) bool {
 	return false
 }
 
-// Only will return a new slice containing only the elements that return
+// Select will return a new slice containing only the elements that return
 // true from the condition. The returned slice may contain zero elements (nil).
 //
-// SliceTypeWithout works in the opposite way as SliceTypeOnly.
-func (ss SliceType) Only(condition func(ElementType) bool) (ss2 SliceType) {
+// Unselect works in the opposite way as Select.
+func (ss SliceType) Select(condition func(ElementType) bool) (ss2 SliceType) {
 	for _, s := range ss {
 		if condition(s) {
 			ss2 = append(ss2, s)
@@ -36,10 +36,10 @@ func (ss SliceType) Only(condition func(ElementType) bool) (ss2 SliceType) {
 	return
 }
 
-// Without works the same as Only, with a negated condition. That is, it will
+// Unselect works the same as Select, with a negated condition. That is, it will
 // return a new slice only containing the elements that returned false from the
 // condition. The returned slice may contain zero elements (nil).
-func (ss SliceType) Without(condition func(ElementType) bool) (ss2 SliceType) {
+func (ss SliceType) Unselect(condition func(ElementType) bool) (ss2 SliceType) {
 	for _, s := range ss {
 		if !condition(s) {
 			ss2 = append(ss2, s)


Test patch:
diff --git a/pie/carpointers_test.go b/pie/carpointers_test.go
index 01e03f4..6ce981d 100644
--- a/pie/carpointers_test.go
+++ b/pie/carpointers_test.go
@@ -40,11 +40,11 @@ func TestCarPointers_Contains(t *testing.T) {
 	}
 }
 
-var carPointersOnlyAndWithoutTests = []struct {
+var carPointersSelectTests = []struct {
 	ss                carPointers
 	condition         func(*car) bool
-	expectedOnly      carPointers
-	expectedWithout   carPointers
+	expectedSelect    carPointers
+	expectedUnselect  carPointers
 	expectedTransform carPointers
 }{
 	{
@@ -67,26 +67,26 @@ var carPointersOnlyAndWithoutTests = []struct {
 	},
 }
 
-func TestCarPointers_Only(t *testing.T) {
-	for _, test := range carPointersOnlyAndWithoutTests {
+func TestCarPointers_Select(t *testing.T) {
+	for _, test := range carPointersSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableCarPointers(t, &test.ss)()
-			assert.Equal(t, test.expectedOnly, test.ss.Only(test.condition))
+			assert.Equal(t, test.expectedSelect, test.ss.Select(test.condition))
 		})
 	}
 }
 
-func TestCarPointers_Without(t *testing.T) {
-	for _, test := range carPointersOnlyAndWithoutTests {
+func TestCarPointers_Unselect(t *testing.T) {
+	for _, test := range carPointersSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableCarPointers(t, &test.ss)()
-			assert.Equal(t, test.expectedWithout, test.ss.Without(test.condition))
+			assert.Equal(t, test.expectedUnselect, test.ss.Unselect(test.condition))
 		})
 	}
 }
 
 func TestCarPointers_Transform(t *testing.T) {
-	for _, test := range carPointersOnlyAndWithoutTests {
+	for _, test := range carPointersSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableCarPointers(t, &test.ss)()
 			assert.Equal(t, test.expectedTransform, test.ss.Transform(func(c *car) *car {
diff --git a/pie/cars_test.go b/pie/cars_test.go
index 4f599d8..4b0ad42 100644
--- a/pie/cars_test.go
+++ b/pie/cars_test.go
@@ -31,11 +31,11 @@ func TestCars_Contains(t *testing.T) {
 	}
 }
 
-var carsOnlyAndWithoutTests = []struct {
+var carsSelectTests = []struct {
 	ss                cars
 	condition         func(car) bool
-	expectedOnly      cars
-	expectedWithout   cars
+	expectedSelect    cars
+	expectedUnselect  cars
 	expectedTransform cars
 }{
 	{
@@ -58,26 +58,26 @@ var carsOnlyAndWithoutTests = []struct {
 	},
 }
 
-func TestCars_Only(t *testing.T) {
-	for _, test := range carsOnlyAndWithoutTests {
+func TestCars_Select(t *testing.T) {
+	for _, test := range carsSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableCars(t, &test.ss)()
-			assert.Equal(t, test.expectedOnly, test.ss.Only(test.condition))
+			assert.Equal(t, test.expectedSelect, test.ss.Select(test.condition))
 		})
 	}
 }
 
-func TestCars_Without(t *testing.T) {
-	for _, test := range carsOnlyAndWithoutTests {
+func TestCars_Unselect(t *testing.T) {
+	for _, test := range carsSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableCars(t, &test.ss)()
-			assert.Equal(t, test.expectedWithout, test.ss.Without(test.condition))
+			assert.Equal(t, test.expectedUnselect, test.ss.Unselect(test.condition))
 		})
 	}
 }
 
 func TestCars_Transform(t *testing.T) {
-	for _, test := range carsOnlyAndWithoutTests {
+	for _, test := range carsSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableCars(t, &test.ss)()
 			assert.Equal(t, test.expectedTransform, test.ss.Transform(func(car car) car {
diff --git a/pie/float64s_test.go b/pie/float64s_test.go
index 096a61c..468fcaa 100644
--- a/pie/float64s_test.go
+++ b/pie/float64s_test.go
@@ -29,11 +29,11 @@ func TestFloat64s_Contains(t *testing.T) {
 	}
 }
 
-var float64sOnlyAndWithoutTests = []struct {
+var float64sSelectTests = []struct {
 	ss                Float64s
 	condition         func(float64) bool
-	expectedOnly      Float64s
-	expectedWithout   Float64s
+	expectedSelect    Float64s
+	expectedUnselect  Float64s
 	expectedTransform Float64s
 }{
 	{
@@ -56,26 +56,26 @@ var float64sOnlyAndWithoutTests = []struct {
 	},
 }
 
-func TestFloat64s_Only(t *testing.T) {
-	for _, test := range float64sOnlyAndWithoutTests {
+func TestFloat64s_Select(t *testing.T) {
+	for _, test := range float64sSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableFloat64s(t, &test.ss)()
-			assert.Equal(t, test.expectedOnly, test.ss.Only(test.condition))
+			assert.Equal(t, test.expectedSelect, test.ss.Select(test.condition))
 		})
 	}
 }
 
-func TestFloat64s_Without(t *testing.T) {
-	for _, test := range float64sOnlyAndWithoutTests {
+func TestFloat64s_Unselect(t *testing.T) {
+	for _, test := range float64sSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableFloat64s(t, &test.ss)()
-			assert.Equal(t, test.expectedWithout, test.ss.Without(test.condition))
+			assert.Equal(t, test.expectedUnselect, test.ss.Unselect(test.condition))
 		})
 	}
 }
 
 func TestFloat64s_Transform(t *testing.T) {
-	for _, test := range float64sOnlyAndWithoutTests {
+	for _, test := range float64sSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableFloat64s(t, &test.ss)()
 			assert.Equal(t, test.expectedTransform, test.ss.Transform(func(a float64) float64 {
diff --git a/pie/ints_test.go b/pie/ints_test.go
index 850c788..6ac65e4 100644
--- a/pie/ints_test.go
+++ b/pie/ints_test.go
@@ -28,11 +28,11 @@ func TestInts_Contains(t *testing.T) {
 	}
 }
 
-var intsOnlyAndWithoutTests = []struct {
+var intsSelectTests = []struct {
 	ss                Ints
 	condition         func(int) bool
-	expectedOnly      Ints
-	expectedWithout   Ints
+	expectedSelect    Ints
+	expectedUnselect  Ints
 	expectedTransform Ints
 }{
 	{
@@ -55,24 +55,24 @@ var intsOnlyAndWithoutTests = []struct {
 	},
 }
 
-func TestInts_Only(t *testing.T) {
-	for _, test := range intsOnlyAndWithoutTests {
+func TestInts_Select(t *testing.T) {
+	for _, test := range intsSelectTests {
 		t.Run("", func(t *testing.T) {
-			assert.Equal(t, test.expectedOnly, test.ss.Only(test.condition))
+			assert.Equal(t, test.expectedSelect, test.ss.Select(test.condition))
 		})
 	}
 }
 
-func TestInts_Without(t *testing.T) {
-	for _, test := range intsOnlyAndWithoutTests {
+func TestInts_Unselect(t *testing.T) {
+	for _, test := range intsSelectTests {
 		t.Run("", func(t *testing.T) {
-			assert.Equal(t, test.expectedWithout, test.ss.Without(test.condition))
+			assert.Equal(t, test.expectedUnselect, test.ss.Unselect(test.condition))
 		})
 	}
 }
 
 func TestInts_Transform(t *testing.T) {
-	for _, test := range intsOnlyAndWithoutTests {
+	for _, test := range intsSelectTests {
 		t.Run("", func(t *testing.T) {
 			assert.Equal(t, test.expectedTransform, test.ss.Transform(func(i int) int {
 				return i + 5
diff --git a/pie/strings_test.go b/pie/strings_test.go
index 12a3de3..07627a3 100644
--- a/pie/strings_test.go
+++ b/pie/strings_test.go
@@ -31,11 +31,11 @@ func TestStrings_Contains(t *testing.T) {
 	}
 }
 
-var stringsOnlyAndWithoutTests = []struct {
+var stringsSelectTests = []struct {
 	ss                Strings
 	condition         func(string) bool
-	expectedOnly      Strings
-	expectedWithout   Strings
+	expectedSelect    Strings
+	expectedUnselect  Strings
 	expectedTransform Strings
 }{
 	{
@@ -58,26 +58,26 @@ var stringsOnlyAndWithoutTests = []struct {
 	},
 }
 
-func TestStrings_Only(t *testing.T) {
-	for _, test := range stringsOnlyAndWithoutTests {
+func TestStrings_Select(t *testing.T) {
+	for _, test := range stringsSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableStrings(t, &test.ss)()
-			assert.Equal(t, test.expectedOnly, test.ss.Only(test.condition))
+			assert.Equal(t, test.expectedSelect, test.ss.Select(test.condition))
 		})
 	}
 }
 
-func TestStrings_Without(t *testing.T) {
-	for _, test := range stringsOnlyAndWithoutTests {
+func TestStrings_Unselect(t *testing.T) {
+	for _, test := range stringsSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableStrings(t, &test.ss)()
-			assert.Equal(t, test.expectedWithout, test.ss.Without(test.condition))
+			assert.Equal(t, test.expectedUnselect, test.ss.Unselect(test.condition))
 		})
 	}
 }
 
 func TestStrings_Transform(t *testing.T) {
-	for _, test := range stringsOnlyAndWithoutTests {
+	for _, test := range stringsSelectTests {
 		t.Run("", func(t *testing.T) {
 			defer assertImmutableStrings(t, &test.ss)()
 			assert.Equal(t, test.expectedTransform, test.ss.Transform(strings.ToUpper))