Project

General

Profile

Actions

Feature #16697

closed

Hash.ruby2_keywords_hash?(value) should support any object

Added by Eregon (Benoit Daloze) over 4 years ago. Updated almost 4 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:97554]

Description

But currently it raises, which makes it needlessly inconvenient to use:

> Hash.ruby2_keywords_hash?({})
=> false
> Hash.ruby2_keywords_hash?("hello")
Traceback (most recent call last):
        5: from /home/eregon/.rubies/ruby-trunk/bin/irb:23:in `<main>'
        4: from /home/eregon/.rubies/ruby-trunk/bin/irb:23:in `load'
        3: from /home/eregon/prefix/ruby-trunk/lib/ruby/gems/2.8.0/gems/irb-1.2.3/exe/irb:11:in `<top (required)>'
        2: from (irb):4
        1: from (irb):4:in `ruby2_keywords_hash?'
TypeError (wrong argument type String (expected Hash))

See https://github.com/ruby/ruby/pull/2966/files#r394741112 for a motivating example.

I'd like to suggest backporting this to 2.7 too.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0