--00163630e87f7b4251046789ed90
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
I did take a look in the problem:
static VALUE
rb_ary_flatten(int argc, VALUE *argv, VALUE ary)
{
int mod , level 1;
VALUE result, lv;
rb_scan_args(argc, argv, "01", &lv);
if (!NIL_P(lv)) level UM2INT(lv);
if (level 0) return ary;
result latten(ary, level, &mod);
OBJ_INFECT(result, ary);
return result;
}
In the line
if (level 0) return ary;
you will get the reference to the original array, instead of
a reference to a clone.
The problem is: this is a bug or a feature? ¿µhat is, what is the behavior that we want when calling
flatten with 0, since this call doesn't make much sense.
It is easy to fix it, but I don't know if I should. If you guys
think it is a good idea, that I can take some time to do that.
Bye!
Rafael Schouery
VidaGeek.net
On Wed, Apr 8, 2009 at 8:01 PM, Paul Lewis <redmine / ruby-lang.org> wrote:
> Bug #1367: flatten(0) is not consistent with flatten(), flatten(1), etc.
> http://redmine.ruby-lang.org/issues/show/1367
>
> Author: Paul Lewis
> Status: Open, Priority: Normal
> Category: core
> ruby -v: ruby 1.9.0 (2008-06-20 revision 17482) [i486-linux]
>
>> a 1, 2]
>> a2 .flatten
>> a2 << :a
>> a2
>