From: shevegen@... Date: 2017-08-10T21:25:49+00:00 Subject: [ruby-core:82338] [Ruby trunk Bug#13799] ENV.dup returns a plain Object Issue #13799 has been updated by shevegen (Robert A. Heiler). Interesting. https://ruby-doc.org/core-2.4.1/ENV.html does not mention #dup so perhaps this comes from Hash or some other upstream object? I also can not quite think of a use case for .dup there, perhaps someone can explain why ENV has it? On a side note, does anyone know why the documentation above does not mention #dup? ---------------------------------------- Bug #13799: ENV.dup returns a plain Object https://bugs.ruby-lang.org/issues/13799#change-66132 * Author: sylvain.joyeux (Sylvain Joyeux) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: 2.1.9, 2.2.5, 2.3.3, 2.4.1 * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- 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 => # irb(main):006:0> ENV.dup['PATH'] NoMethodError: undefined method `[]' for # from (irb):6 from /home/doudou/.rbenv/versions/2.4.1/bin/irb:11:in `
' irb(main):007:0> ~~~ The only way I found to get a copy is Hash[ENV] -- https://bugs.ruby-lang.org/ Unsubscribe: