Project

General

Profile

Actions

Feature #18279

open

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

Added by zw963 (Wei Zheng) 7 months ago. Updated 6 months ago.

Status:
Assigned
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

Also available in: Atom PDF