Project

General

Profile

Actions

Bug #13799

closed

ENV.dup returns a plain Object

Added by sylvain.joyeux (Sylvain Joyeux) over 6 years ago. Updated over 6 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
2.1.9, 2.2.5, 2.3.3, 2.4.1
[ruby-core:82329]

Description

I was doing ENV.dup to get a copy of the environment that can be modified without affecting ENV. However, ENV.dup returns a plain Object

irb(main):005:0> ENV.dup
=> #<Object:0x00000002024fc0>
irb(main):006:0> ENV.dup['PATH']
NoMethodError: undefined method `[]' for #<Object:0x000000020446e0>
        from (irb):6
        from /home/doudou/.rbenv/versions/2.4.1/bin/irb:11:in `<main>'
irb(main):007:0> 

The only way I found to get a copy is Hash[ENV]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0