Project

General

Profile

Actions

Feature #18279

closed

ENV.merge! support multiple arguments as Hash.merge!

Added by zw963 (Wei Zheng) 11 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:105876]

Description

I give a useful example for this.

require 'yaml'
env_files = ['config.yml', 'config.local']
envs = env_files.filter_map {|file| YAML.load_file(file)['env'] if File.file?(file) }
ENV.merge!(*envs) # Raise wrong number of arguments (given 2, expected 1)


For now, above code have do like this in ruby 3.0.2

ENV.merge!({}.merge!(*envs))
Actions #1

Updated by zw963 (Wei Zheng) 11 months ago

  • Subject changed from ENV.merge! support multile arguments as hash. to ENV.merge! support multile arguments as Hash.merge!
  • Description updated (diff)

Updated by ko1 (Koichi Sasada) 10 months ago

  • Status changed from Open to Assigned
  • Assignee set to matz (Yukihiro Matsumoto)

Hash#merge!(*other) accepts multiple values, so I think it is acceptable.

Matz, how about it?

Updated by nobu (Nobuyoshi Nakada) 10 months ago

  • Subject changed from ENV.merge! support multile arguments as Hash.merge! to ENV.merge! support multiple arguments as Hash.merge!

Updated by matz (Yukihiro Matsumoto) 4 months ago

Accepted.

Matz.

Actions #5

Updated by nobu (Nobuyoshi Nakada) 4 months ago

  • Status changed from Assigned to Closed

Applied in changeset git|278fefb96294adf9d27a78f919c714a31b65ef58.


ENV.merge! support multile arguments [Feature #18279]

Actions

Also available in: Atom PDF