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

ruby-changes:45442

From: marcandre <ko1@a...>
Date: Sat, 4 Feb 2017 03:25:40 +0900 (JST)
Subject: [ruby-changes:45442] marcandRe: r57515 (trunk): lib/ostruct.rb: Fix returned value of each_pair.

marcandre	2017-02-04 03:25:28 +0900 (Sat, 04 Feb 2017)

  New Revision: 57515

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57515

  Log:
    lib/ostruct.rb: Fix returned value of each_pair.
    
    From a patch by Marcus Stollsteimer. [Fixes #13169]

  Modified files:
    trunk/lib/ostruct.rb
    trunk/test/ostruct/test_ostruct.rb
Index: lib/ostruct.rb
===================================================================
--- lib/ostruct.rb	(revision 57514)
+++ lib/ostruct.rb	(revision 57515)
@@ -130,6 +130,7 @@ class OpenStruct https://github.com/ruby/ruby/blob/trunk/lib/ostruct.rb#L130
   def each_pair
     return to_enum(__method__) { @table.size } unless block_given?
     @table.each_pair{|p| yield p}
+    self
   end
 
   #
Index: test/ostruct/test_ostruct.rb
===================================================================
--- test/ostruct/test_ostruct.rb	(revision 57514)
+++ test/ostruct/test_ostruct.rb	(revision 57515)
@@ -141,6 +141,7 @@ class TC_OpenStruct < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ostruct/test_ostruct.rb#L141
   def test_each_pair
     h = {name: "John Smith", age: 70, pension: 300}
     os = OpenStruct.new(h)
+    assert_same os, os.each_pair{ }
     assert_equal '#<Enumerator: #<OpenStruct name="John Smith", age=70, pension=300>:each_pair>', os.each_pair.inspect
     assert_equal [[:name, "John Smith"], [:age, 70], [:pension, 300]], os.each_pair.to_a
     assert_equal 3, os.each_pair.size

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

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