Project

General

Profile

Actions

Feature #4772

closed

Hash#add_keys

Added by yimutang (Joey Zhou) about 11 years ago. Updated over 9 years ago.

Status:
Rejected
Priority:
Normal
Target version:
[ruby-core:36419]

Description

Hi, do you want to add a new method Hash#add_keys in a new version?

hash = Hash.new {|h,k| k.to_s + "foo" }
hash.add_keys("a","b","c") # the value is hash's default obj or proc value

If there's a word list file, I want to make the words keys of a hash, maybe I can write:

hash = {}
hash.add_keys(*open("file").readlines.map(&:chomp))

Actions

Also available in: Atom PDF