ExampleSet_stringSet demonstrates using generic Set with strings
()
| 72 | |
| 73 | // ExampleSet_stringSet demonstrates using generic Set with strings |
| 74 | func ExampleSet_stringSet() { |
| 75 | fruits := set.Create("apple", "banana", "cherry") |
| 76 | |
| 77 | fruits.Add("date") |
| 78 | fruits.Add("banana") // duplicate, won't be added |
| 79 | |
| 80 | fmt.Println("Has apple:", fruits.Contains("apple")) |
| 81 | fmt.Println("Count:", len(fruits)) |
| 82 | fmt.Println("Fruits:", set.ToSliceOrdered(fruits)) |
| 83 | |
| 84 | // Output: |
| 85 | // Has apple: true |
| 86 | // Count: 4 |
| 87 | // Fruits: [apple banana cherry date] |
| 88 | } |
| 89 | |
| 90 | // ExampleSet_float64Set demonstrates using Set with floating point numbers |
| 91 | func ExampleSet_float64Set() { |
nothing calls this directly
no test coverage detected