March 2019
Intermediate to advanced
336 pages
9h 9m
English
In the following code snippet, the main method creates Set, invokes the New method, and adds elements 1 and 2. The check is done if element 1 exists in the set:
// main methodfunc main() { var set *Set set = &Set{} set.New() set.AddElement(1) set.AddElement(2) fmt.Println(set) fmt.Println(set.ContainsElement(1))}
Run the following command to execute the set.go file:
go run set.go
After executing the preceding command, we get the following output:

Let's take a look at the InterSect method in the next section.
Read now
Unlock full access