Robert Klemme
7/4/2008 7:27:00 AM
2008/7/4 Pe=F1a, Botp <botp@delmonte-phil.com>:
> From: Yukihiro Matsumoto [mailto:matz@ruby-lang.org]
> # <botp@delmonte-phil.com> writes:
> # |current test:
> # |
> # |1.9 not sorted
> # |1.8.6 not sorted
> # |1.8.7 sorted
> # |
> # |i prefer 1.8.7 default behaviour
> # Hmm, from my understanding, 1.9 preserves the order, prior version
> # does not. Could you show us the test you got the above conclusion?
>
> sir Matz, as requested,
>
>> [RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_REVISION]
> =3D> ["1.9.0", "2008-06-20", 17482]
>
>> RUBY_PLATFORM
> =3D> "i386-mswin32"
>
>> a =3D [ 1, 2, 3, 4, 7, 9, 11, 12, 13, 14 ]
> =3D> [1, 2, 3, 4, 7, 9, 11, 12, 13, 14]
>
>> a.group_by { |i| i % 3 }
> =3D> {1=3D>[1, 4, 7, 13], 2=3D>[2, 11, 14], 0=3D>[3, 9, 12]}
>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> at this point, 1.9 and 1.8.7 differs
Where exactly? I cannot seem to see it. Above and below look
identical. What am I missing?
>> h=3Da.group_by { |i| i % 3 }
> =3D> {1=3D>[1, 4, 7, 13], 2=3D>[2, 11, 14], 0=3D>[3, 9, 12]}
I get
09:29:30 bas$ ruby --version
ruby 1.8.7 (2008-06-20 patchlevel 22) [i386-cygwin]
09:29:40 bas$ ruby -e 'p [ 1, 2, 3, 4, 7, 9, 11, 12, 13, 14 ].group_by
{ |i| i % 3 }'
{0=3D>[3, 9, 12], 1=3D>[1, 4, 7, 13], 2=3D>[2, 11, 14]}
09:29:43 bas$ ruby19 --version
ruby 1.9.0 (2008-03-01 revision 15664) [i386-cygwin]
09:29:47 bas$ ruby19 -e 'p [ 1, 2, 3, 4, 7, 9, 11, 12, 13, 14
].group_by { |i| i % 3 }'
{1=3D>[1, 4, 7, 13], 2=3D>[2, 11, 14], 0=3D>[3, 9, 12]}
And there *is* a difference.
Kind regards
robert
--=20
use.inject do |as, often| as.you_can - without end