ExampleNew demonstrates creating an empty set and adding elements
()
| 226 | |
| 227 | // ExampleNew demonstrates creating an empty set and adding elements |
| 228 | func ExampleNew() { |
| 229 | // Create an empty set of strings |
| 230 | tags := set.New[string]() |
| 231 | |
| 232 | // Add elements one by one |
| 233 | tags.Add("go") |
| 234 | tags.Add("generics") |
| 235 | tags.Add("set") |
| 236 | tags.Add("go") // duplicate, ignored |
| 237 | |
| 238 | fmt.Println("Tags:", set.ToSliceOrdered(tags)) |
| 239 | fmt.Println("Count:", len(tags)) |
| 240 | |
| 241 | // Output: |
| 242 | // Tags: [generics go set] |
| 243 | // Count: 3 |
| 244 | } |
| 245 | |
| 246 | // ExampleCreate demonstrates creating a set with initial values |
| 247 | func ExampleCreate() { |
nothing calls this directly
no test coverage detected