[前][次][番号順一覧][スレッド一覧]

ruby-changes:58230

From: Burdette <ko1@a...>
Date: Sun, 13 Oct 2019 09:48:42 +0900 (JST)
Subject: [ruby-changes:58230] 6a1809e2e1 (master): Enhance doc for ENV.delete

https://git.ruby-lang.org/ruby.git/commit/?id=6a1809e2e1

From 6a1809e2e1a95c14cfb72701df480e3ebccd4b24 Mon Sep 17 00:00:00 2001
From: Burdette Lamar <BurdetteLamar@Y...>
Date: Sat, 12 Oct 2019 19:48:20 -0500
Subject: Enhance doc for ENV.delete


diff --git a/hash.c b/hash.c
index d00a09d..9b5f978 100644
--- a/hash.c
+++ b/hash.c
@@ -4769,9 +4769,21 @@ env_delete(VALUE name) https://github.com/ruby/ruby/blob/trunk/hash.c#L4769
  *   ENV.delete(name)                  -> value
  *   ENV.delete(name) { |name| block } -> value
  *
- * Deletes the environment variable with +name+ and returns the value of the
- * variable.  If a block is given it will be called when the named environment
- * does not exist.
+ * Deletes the environment variable with +name+ if it exists and returns its value:
+ *   ENV['foo'] = '0'
+ *   ENV.delete('foo') # => '0'
+ * Returns +nil+ if the named environment variable does not exist:
+ *   ENV.delete('foo') # => nil
+ * If a block given and the environment variable does not exist,
+ * yields +name+ to the block and returns +nil+:
+ *   ENV.delete('foo') { |name| puts name } # => nil
+ *   foo
+ * If a block given and the environment variable exists,
+ * deletes the environment variable and returns its value (ignoring the block):
+ *   ENV['foo'] = '0'
+ *   ENV.delete('foo') { |name| fail 'ignored' } # => "0"
+ * Raises TypeError if +name+ is not a String and cannot be coerced with \#to_str:
+ *   ENV.delete(Object.new) # => TypeError raised
  */
 static VALUE
 env_delete_m(VALUE obj, VALUE name)
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]