[#7708] Bug in libsnmp-ruby1.8 — Hadmut Danisch <hadmut@...>

Hi,

8 messages 2006/04/11
[#7709] Re: Bug in libsnmp-ruby1.8 — Eric Hodel <drbrain@...7.net> 2006/04/11

On Apr 11, 2006, at 6:23 AM, Hadmut Danisch wrote:

[#7770] Re: possible defect in array.c — "Brown, Warren" <warrenbrown@...>

> rb_range_beg_len (in range.c) does set beg and len.

13 messages 2006/04/26
[#7771] Re: possible defect in array.c — "Pat Eyler" <rubypate@...> 2006/04/26

On 4/26/06, Brown, Warren <warrenbrown@aquire.com> wrote:

Re: [ ruby-Bugs-4060 ] Array#- fails on arrays of user-defined classes

From: Eric Hodel <drbrain@...7.net>
Date: 2006-04-10 21:30:37 UTC
List: ruby-core #7706
On Apr 10, 2006, at 12:38 PM, noreply@rubyforge.org wrote:

> Bugs item #4060, was opened at 2006-04-10 14:38
> You can respond by visiting:
> http://rubyforge.org/tracker/? 
> func=detail&atid=1698&aid=4060&group_id=426
>
> Summary: Array#- fails on arrays of user-defined classes
>
> Initial Comment:
> Array#- does't appear to use ==, === or eql?.  I think it uses  
> something below the ruby level.
>
> When working with user-defined classes, Array#- considers identical  
> objects to be equal.
>
> I would understand if it used .equal?, but it doesn't because  
> Array#- works on strings as if == was called.  Here's an example.
>
> --------------------
> class MyClass
>   def ==(b)
>     true
>   end
> end
>
> p [MyClass.new, MyClass.new, MyClass.new] - [MyClass.new, MyClass.new]
> --------------------
>
> Expected: []
> Observed: [#<MyClass:0x26080>, #<MyClass:0x2606c>, #<MyClass:0x26058>]

It uses #hash and #eql?  Since you didn't define #hash, #eql? will  
never be called.

-- 
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com



In This Thread