Member-only story

Go

Show all elements from slice not contained in another slice

in Go.

Donald Le

--

Photo by Anthony Ievlev on Unsplash

For example the two slices

First we create a find function to find whether a string exist in a slice.

Then iterate in for loop

Running the code will show

[test donald ad thuy]
ad
thuy
2

Which show 2 elements do not exist in the other slice and their value is “ad” and “thuy”.

~~ Happy coding guys ~~

--

--

No responses yet