Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
common-go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Life 2
common-go
Commits
4fd2ff85
Commit
4fd2ff85
authored
Aug 15, 2019
by
Phillip Couto
🔨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Slice function to Strings set type.
parent
4087f87d
Pipeline
#11249
passed with stage
in 12 seconds
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
sets/strings.go
sets/strings.go
+9
-0
sets/strings_test.go
sets/strings_test.go
+3
-0
No files found.
sets/strings.go
View file @
4fd2ff85
...
...
@@ -50,3 +50,12 @@ func (ss *Strings) Intersect(ss2 *Strings) *Strings {
data
:
results
,
}
}
//Creates a slice of the values in the set, the values are not sorted
func
(
ss
*
Strings
)
Slice
()
[]
string
{
results
:=
make
([]
string
,
0
,
len
(
ss
.
data
))
for
v
:=
range
ss
.
data
{
results
=
append
(
results
,
v
)
}
return
results
}
sets/strings_test.go
View file @
4fd2ff85
...
...
@@ -24,4 +24,7 @@ func TestStrings(t *testing.T) {
require
.
True
(
t
,
s3
.
Contains
(
"B"
))
require
.
False
(
t
,
s3
.
Contains
(
"A"
))
require
.
False
(
t
,
s3
.
Contains
(
"C"
))
s1Slice
:=
s
.
Slice
()
require
.
ElementsMatch
(
t
,
s1Slice
,
[]
string
{
"A"
,
"B"
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment