Issue #16173 has been updated by nobu (Nobuyoshi Nakada).


burdettelamar / yahoo.com (Burdette Lamar) wrote:
> Thanks, @alanwu.  I'm refreshing diff.txt with more fulsome documentation, along with enhanced testing.

Thank you for the patch.

```diff
+ * Deletes the environment variable for +name+ if it exists (ignoring the block, if given); returns +nil+:
+ *   ENV.delete('LINES') # => '300'
+ *   ENV.delete('COLUMNS') { |name| fail 'boo' } # => '120'
```

It should return the old value, not `nil`.

```diff
+ * Calls the block and returns +nil+ if the environment variable does not exist and block given:
+ *   ENV.delete('NOSUCH') { |name| } # => nil
```

Non-empty block and non-nil result feels better to me.

----------------------------------------
Bug #16173: ENV.delete returns nil when name does not exist and block given
https://bugs.ruby-lang.org/issues/16173#change-81803

* Author: burdettelamar / yahoo.com (Burdette Lamar)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.4p104 (2019-08-28 revision 67798) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Attached diff.txt:

* ENV.delete for nonexistent name and block given:
  * Test enhanced to verify return value is nil.
  * Documentation corrected to say that return value is nil, not value.


---Files--------------------------------
diff.txt (2.22 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>