Project

General

Profile

Bug #13169

Fix OpenStruct#each_pair return value

Added by stomar (Marcus Stollsteimer) about 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
[ruby-core:79309]

Description

ostruct.rb: fix OpenStruct#each_pair return value

* lib/ostruct.rb (OpenStruct#each_pair): let #each_pair
  with block return self instead of the internal hash table.

Currently OpenStruct#each_pair with block returns the internal hash table, while usually #each, #each_key, #each_byte, and similar methods return self. Struct#each_pair also returns self.

require "ostruct"
person = OpenStruct.new(name: "John", age: 70)

person                # => #<OpenStruct name="John", age=70>
person.each_pair { }  # => {:name=>"John", :age=>70}

I don't know whether this is intended behavior or only an oversight.

The patch makes OpenStruct#each_pair return self, and also adds a test. (I do not know anything about how tests/specs in the Ruby source are organized, I hope it's fine.)


Files

ostruct_each_pair.patch (908 Bytes) ostruct_each_pair.patch stomar (Marcus Stollsteimer), 01/30/2017 08:51 PM

Associated revisions

Revision 4d7b999c
Added by marcandre (Marc-Andre Lafortune) about 2 years ago

lib/ostruct.rb: Fix returned value of each_pair.

From a patch by Marcus Stollsteimer. [Fixes #13169]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57515
Added by marcandre (Marc-Andre Lafortune) about 2 years ago

lib/ostruct.rb: Fix returned value of each_pair.

From a patch by Marcus Stollsteimer. [Fixes #13169]

Revision 57515
Added by marcandre (Marc-Andre Lafortune) about 2 years ago

lib/ostruct.rb: Fix returned value of each_pair.

From a patch by Marcus Stollsteimer. [Fixes #13169]

Revision 57515
Added by marcandre (Marc-Andre Lafortune) about 2 years ago

lib/ostruct.rb: Fix returned value of each_pair.

From a patch by Marcus Stollsteimer. [Fixes #13169]

Revision c9f62d7f
Added by naruse (Yui NARUSE) about 2 years ago

merge revision(s) 57515: [Backport #13169]

lib/ostruct.rb: Fix returned value of each_pair.

From a patch by Marcus Stollsteimer. [Fixes #13169]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@57893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57893
Added by naruse (Yui NARUSE) about 2 years ago

merge revision(s) 57515: [Backport #13169]

lib/ostruct.rb: Fix returned value of each_pair.

From a patch by Marcus Stollsteimer. [Fixes #13169]

Revision fc7fa64b
Added by usa (Usaku NAKAMURA) about 2 years ago

merge revision(s) 57515: [Backport #13169]

lib/ostruct.rb: Fix returned value of each_pair.

From a patch by Marcus Stollsteimer. [Fixes #13169]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 58100
Added by usa (Usaku NAKAMURA) about 2 years ago

merge revision(s) 57515: [Backport #13169]

lib/ostruct.rb: Fix returned value of each_pair.

From a patch by Marcus Stollsteimer. [Fixes #13169]

Revision 7f04247e
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 57515: [Backport #13169]

lib/ostruct.rb: Fix returned value of each_pair.

From a patch by Marcus Stollsteimer. [Fixes #13169]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 58178
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 57515: [Backport #13169]

lib/ostruct.rb: Fix returned value of each_pair.

From a patch by Marcus Stollsteimer. [Fixes #13169]

History

#1

Updated by marcandre (Marc-Andre Lafortune) about 2 years ago

  • Status changed from Open to Closed

Applied in changeset r57515.


lib/ostruct.rb: Fix returned value of each_pair.

From a patch by Marcus Stollsteimer. [Fixes #13169]

Updated by marcandre (Marc-Andre Lafortune) about 2 years ago

Thank you for the great patch :-)

Updated by naruse (Yui NARUSE) about 2 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: DONE

ruby_2_4 r57893 merged revision(s) 57515.

Updated by nagachika (Tomoyuki Chikanaga) about 2 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: DONE to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE

Updated by usa (Usaku NAKAMURA) about 2 years ago

  • Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE to 2.2: DONE, 2.3: REQUIRED, 2.4: DONE

ruby_2_2 r58100 merged revision(s) 57515.

Updated by nagachika (Tomoyuki Chikanaga) about 2 years ago

  • Backport changed from 2.2: DONE, 2.3: REQUIRED, 2.4: DONE to 2.2: DONE, 2.3: DONE, 2.4: DONE

ruby_2_3 r58178 merged revision(s) 57515.

Also available in: Atom PDF