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

ruby-changes:60165

From: Marcus <ko1@a...>
Date: Sun, 23 Feb 2020 00:38:29 +0900 (JST)
Subject: [ruby-changes:60165] 77dcc2c822 (master): hash.c: [DOC] fix examples for ENV.merge!

https://git.ruby-lang.org/ruby.git/commit/?id=77dcc2c822

From 77dcc2c8228f6a69e7cd4c4d72f4ac6c4116d27c Mon Sep 17 00:00:00 2001
From: Marcus Stollsteimer <sto.mar@w...>
Date: Sat, 22 Feb 2020 16:32:37 +0100
Subject: hash.c: [DOC] fix examples for ENV.merge!


diff --git a/hash.c b/hash.c
index 9c723a0..0967bff 100644
--- a/hash.c
+++ b/hash.c
@@ -6372,18 +6372,19 @@ env_update_block_i(VALUE key, VALUE val, VALUE _) https://github.com/ruby/ruby/blob/trunk/hash.c#L6372
  *   ENV.merge!('foo' => '4') # => {"bar"=>"1", "foo"=>"4"}
  * For an already-existing name, if block given,
  * yields the name, its ENV value, and its hash value;
- * the  block's return value becomes the new name:
+ * the block's return value becomes the new name:
  *   ENV.merge!('foo' => '5') { |name, env_val, hash_val | env_val + hash_val } # => {"bar"=>"1", "foo"=>"45"}
  * Raises an exception if a name or value is invalid
  * (see {Invalid Names and Values}[#class-ENV-label-Invalid+Names+and+Values]);
+ *   ENV.replace('foo' => '0', 'bar' => '1')
  *   ENV.merge!('foo' => '6', :bar => '7', 'baz' => '9') # Raises TypeError (no implicit conversion of Symbol into String)
- *   ENV # => {"bar"=>"1", "baz"=>"2", "foo"=>"6"}
- *   ENV.merge!('foo' => '7', 'bar' => 8, 'baz' => '9')
- *   ENV # => {"bar"=>"1", "baz"=>"2", "foo"=>"7"} TypeError (no implicit conversion of Integer into String)
+ *   ENV # => {"bar"=>"1", "foo"=>"6"}
+ *   ENV.merge!('foo' => '7', 'bar' => 8, 'baz' => '9') # Raises TypeError (no implicit conversion of Integer into String)
+ *   ENV # => {"bar"=>"1", "foo"=>"7"}
  * Raises an exception if the block returns an invalid name:
  * (see {Invalid Names and Values}[#class-ENV-label-Invalid+Names+and+Values]):
  *   ENV.merge!('bat' => '8', 'foo' => '9') { |name, env_val, hash_val | 10 } # Raises TypeError (no implicit conversion of Integer into String)
- *   ENV # => {"bar"=>"1", "bat"=>"8", "baz"=>"2", "foo"=>"75"}
+ *   ENV # => {"bar"=>"1", "bat"=>"8", "foo"=>"7"}
  *
  * Note that for the exceptions above,
  * hash pairs preceding an invalid name or value are processed normally;
-- 
cgit v0.10.2


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

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