MCPcopy
hub / github.com/minio/minio-go / ExampleNew

Function ExampleNew

pkg/set/example_test.go:228–244  ·  view source on GitHub ↗

ExampleNew demonstrates creating an empty set and adding elements

()

Source from the content-addressed store, hash-verified

226
227// ExampleNew demonstrates creating an empty set and adding elements
228func 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
247func ExampleCreate() {

Callers

nothing calls this directly

Calls 2

ToSliceOrderedFunction · 0.92
AddMethod · 0.45

Tested by

no test coverage detected