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

Function ExampleSet_stringSet

pkg/set/example_test.go:74–88  ·  view source on GitHub ↗

ExampleSet_stringSet demonstrates using generic Set with strings

()

Source from the content-addressed store, hash-verified

72
73// ExampleSet_stringSet demonstrates using generic Set with strings
74func 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
91func ExampleSet_float64Set() {

Callers

nothing calls this directly

Calls 4

CreateFunction · 0.92
ToSliceOrderedFunction · 0.92
AddMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected