Skip to content

Commit 071f715

Browse files
committed
#15 Implement Joiner
1 parent ed1cf24 commit 071f715

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

src/DeclarativeCOS.Joiner.cls

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Class DeclarativeCOS.Joiner
2+
{
3+
4+
ClassMethod join(collection As %Collection.AbstractList, separator As %String = "") As %String
5+
{
6+
if (collection = "") {
7+
return ""
8+
}
9+
10+
set string = ""
11+
12+
set index = ""
13+
14+
for {
15+
set index = collection.Next(index)
16+
17+
quit:index=""
18+
19+
set item = collection.GetAt(index)
20+
21+
if (string = "") {
22+
set string = "" _ item
23+
}
24+
else {
25+
set string = string _ separator _ item
26+
}
27+
}
28+
29+
return string
30+
}
31+
32+
}
33+

0 commit comments

Comments
 (0)