Skip to content

me #5

@cjheath

Description

@cjheath

The following code triggers an unnecessary strong type-check in RBTree#merge!
.../gems/2.2.0/gems/rbtree-pure-0.1.1/lib/rbtree/rb_tree.rb:409:in `merge!': wrong argument type Index (expected RBTree) (TypeError)

The type-check is only needed if the block is given (the other path works with a Hash),
and even that path should use kind_of?, not instance_of?

Even better would be to detect that kind_of?(RBTree) is false and use a generic code path.

require "rbtree"
class Index < RBTree
end
i = Index.new
i[:a] = 1
j = Index.new
j[:b] = 2
j.merge!(i)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions