From: Nobuyoshi Nakada Date: 2007-03-09T18:15:43+09:00 Subject: Re: [ ruby-Patches-9055 ] Dynamic Array#join with block Hi, At Fri, 9 Mar 2007 05:58:48 +0900, Farrel Lifson wrote in [ruby-core:10537]: > On 06/03/07, Nobuyoshi Nakada wrote: > > It sounds like sep can't be omitted. I guess it might be nice > > if ary.join(*seps) yields a, b, *seps. > > I've modified the patch so that it is now called with the > separator being optional and following the two elements that > will be joined. +VALUE +rb_ary_join_block(VALUE ary,VALUE sep) +{ + if (RARRAY_LEN(ary) == 0) return rb_str_new(0,0); + int taint = Qfalse; This results syntax error on non-C99 platforms. And, sorry but the indentation looks quite odd to me. Setting tab width to 2? + switch (TYPE(tmp)) { + case T_STRING: + break; + case T_ARRAY: + { + VALUE args[2]; + args[0] = tmp; + args[1] = sep; + tmp = rb_exec_recursive(recursive_join_block, ary, (VALUE)args); + } + break; + default: + tmp = rb_obj_as_string(tmp); + } -- Nobu Nakada