#217 Str.join() would be nice

mike Thu 1 May 2008

Str has a split method (very handy), but no static join method (also very handy).

Str join(Str[] arr, Str separator := ",")

brian Thu 1 May 2008

join is on List, from docCookbook:

x := ['a', 'b', 'c']
x.join                                        // returns "979899"
x.join(",")                                   // returns "97,98,99"
x.join(",") |Int v->Str| { return v.toChar }  // returns "a,b,c"
x.join("-", &Int.toChar)                      // returns "a-b-c"

mike Thu 1 May 2008

yeah, I realized that after I posted my question. Obviously List is a better place for that method to live.

Login or Signup to reply.