[#18121] [Ruby 1.8.7 - Bug #405] (Open) ssl.rb:31: [BUG] Bus Error — Anonymous <redmine@...>

Issue #405 has been reported by Anonymous.

14 messages 2008/08/04

[#18130] Re: New array methods cycle, choice, shuffle (plus bug in cycle) — Brian Candler <B.Candler@...>

> Seriously though... Array.first is a noun.

10 messages 2008/08/05

[#18319] NEW Command: absolute_path() -- — "C.E. Thornton" <admin@...>

Core,

14 messages 2008/08/16
[#18321] Re: NEW Command: absolute_path() -- — Yukihiro Matsumoto <matz@...> 2008/08/18

Hi,

[#18381] [Bug #496] DRb.start_service(nil) is very slow — Hongli Lai <redmine@...>

Bug #496: DRb.start_service(nil) is very slow

11 messages 2008/08/25

[ruby-core:18393] Re: [Feature #474] Hash#<<

From: Trans <transfire@...>
Date: 2008-08-27 06:33:59 UTC
List: ruby-core #18393

On Aug 27, 1:04=A0am, Yukihiro Matsumoto <m...@ruby-lang.org> wrote:

> Unlike Smalltalk's Dictionaries, Hashes in Ruby does not provide the
> illusion of being sequence of association. =A0So the proposed new method
> makes less sense in Ruby.

Well, there is some correlation. Ruby even indicates it:

  {:a=3D>1, :b=3D>2, :c=3D>3}.to_a

> Besides that, Associative Arrays (which has normal array methods) and
> hashes cannot behave polymorphic.

I don't think it is about creating an illusion. One doesn't need
perfect polymorphism to be useful. Plus it can be useful in and of
itself --at minimal if you're given an associative array and you want
to make a hash out of it:

  a.inject({}){|h,e|h<<e}

But more abstractly it is polymorphism that allow Mixins to work at
all. Now I recall what it was in that old thread that made me thing it
was a good idea:

  h =3D {:a=3D>1, :b=3D>2, :c=3D>3}

  p h.map{ |e| e }

  #=3D> [[:a, 1], [:b, 2], [:c, 3]]

  class Hash
    def <<(a)
      self[a[0]] =3D a[1]
    end
  end

  module Enumerable

    def map(&block)
      o =3D self.class.new
      each do |e|
        o << yield(e)
      end
      o
    end

  end

  p h.map{ |e| e }

  #=3D> {:a=3D>1, :b=3D>2, :c=3D>3}

That's seems very compelling to me.  Currently using #map on a hash is
of very little use, precisely because b/c it creates an associative
array.

T.

In This Thread