Skip to content

Commit 6c29774

Browse files
committed
Fixed Struct#each and #each_pair to return self
1 parent 505176f commit 6c29774

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@
8383
* Fix lexer to detect dereferencing on local variables even when whitespace
8484
is present (`a = 0; a [0]` parses as a deference on a).
8585

86+
* Fix various `Struct` methods. Fixed `#each` and `#each_pair` to return
87+
self.
88+
8689
## 0.5.5 2013-11-25
8790

8891
* Fix regression: add `%i[foo bar]` style words back to lexer

opal/corelib/struct.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,14 @@ def each
8989
return enum_for :each unless block_given?
9090

9191
members.each { |name| yield self[name] }
92+
self
9293
end
9394

9495
def each_pair
9596
return enum_for :each_pair unless block_given?
9697

9798
members.each { |name| yield name, self[name] }
99+
self
98100
end
99101

100102
def eql?(other)

spec/opal/rubyspecs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ core/string/upcase_spec
317317

318318
core/symbol/to_proc_spec
319319

320+
core/struct/each_pair_spec
321+
core/struct/each_spec
320322
core/struct/initialize_spec
321323
core/struct/new_spec
322324

0 commit comments

Comments
 (0)