package tricks_test

import (
	"fmt"
	"strings"

	"github.com/aviddiviner/tricks"
)

func ExampleSlice() {
	animals := []string{"dog", "cat", "bear", "cow", "bull", "pig", "iguana"}

	bearCow := tricks.Slice(animals).
		Map(strings.ToUpper).
		Last(5).
		First(2).
		Value().([]string)

	fmt.Println(bearCow)
	// Output: [BEAR COW]
}

func ExampleSlice_strings() {
	password := tricks.Slice([]rune("abracadabra")).Reverse().Value().([]rune)
	fmt.Println(string(password))
	// Output: arbadacarba
}

// TODO: Add variadic example.

func ExampleTrickSlice_GroupBy() {
	animals := []string{"dog", "cat", "bear", "cow", "bull", "pig", "iguana"}

	byLength := tricks.Slice(animals).
		Copy().
		Sort().
		Reverse().
		GroupBy(func(s string) int { return len(s) }).
		Value().(map[int][]string)

	fmt.Println(byLength[3])
	// Output: [pig dog cow cat]
}

package tricks_test

import (
	"fmt"
	"strings"

	"github.com/aviddiviner/tricks"
)

var animals = []string{"dog", "cat", "bear", "cow", "bull", "pig", "iguana"}

func ExampleSlice() {
	bearCow := tricks.Slice(animals).
		Map(strings.ToUpper).
		Last(5).
		First(2).
		Value().([]string)

	fmt.Println(bearCow)

	// Output: [BEAR COW]
}

func ExampleSlice_groupBy() {
	byLength := tricks.Slice(animals).
		Copy().Sort().
		GroupBy(func(s string) int { return len(s) }).
		Value().(map[int][]string)

	fmt.Println(byLength[3])

	// Output: [cat cow dog pig]
}

func ExampleSlice_strings() {
	password := tricks.Slice([]rune("abracadabra")).Reverse().Value().([]rune)
	fmt.Println(string(password))

	// Output: arbadacarba
}

// TODO: Add variadic example.

--- 
+++ 
@@ -7,9 +7,9 @@
 	"github.com/aviddiviner/tricks"
 )
 
-var animals = []string{"dog", "cat", "bear", "cow", "bull", "pig", "iguana"}
+func ExampleSlice() {
+	animals := []string{"dog", "cat", "bear", "cow", "bull", "pig", "iguana"}
 
-func ExampleSlice() {
 	bearCow := tricks.Slice(animals).
 		Map(strings.ToUpper).
 		Last(5).
@@ -17,26 +17,27 @@
 		Value().([]string)
 
 	fmt.Println(bearCow)
-
 	// Output: [BEAR COW]
-}
-
-func ExampleSlice_groupBy() {
-	byLength := tricks.Slice(animals).
-		Copy().Sort().
-		GroupBy(func(s string) int { return len(s) }).
-		Value().(map[int][]string)
-
-	fmt.Println(byLength[3])
-
-	// Output: [cat cow dog pig]
 }
 
 func ExampleSlice_strings() {
 	password := tricks.Slice([]rune("abracadabra")).Reverse().Value().([]rune)
 	fmt.Println(string(password))
-
 	// Output: arbadacarba
 }
 
 // TODO: Add variadic example.
+
+func ExampleTrickSlice_GroupBy() {
+	animals := []string{"dog", "cat", "bear", "cow", "bull", "pig", "iguana"}
+
+	byLength := tricks.Slice(animals).
+		Copy().
+		Sort().
+		Reverse().
+		GroupBy(func(s string) int { return len(s) }).
+		Value().(map[int][]string)
+
+	fmt.Println(byLength[3])
+	// Output: [pig dog cow cat]
+}
Tweak examples to look better
