Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed Struct#each and #each_pair to return self
  • Loading branch information
adambeynon committed Dec 9, 2013
1 parent 505176f commit 6c29774
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -83,6 +83,9 @@
* Fix lexer to detect dereferencing on local variables even when whitespace
is present (`a = 0; a [0]` parses as a deference on a).

* Fix various `Struct` methods. Fixed `#each` and `#each_pair` to return
self.

## 0.5.5 2013-11-25

* Fix regression: add `%i[foo bar]` style words back to lexer
Expand Down
2 changes: 2 additions & 0 deletions opal/corelib/struct.rb
Expand Up @@ -89,12 +89,14 @@ def each
return enum_for :each unless block_given?

members.each { |name| yield self[name] }
self
end

def each_pair
return enum_for :each_pair unless block_given?

members.each { |name| yield name, self[name] }
self
end

def eql?(other)
Expand Down
2 changes: 2 additions & 0 deletions spec/opal/rubyspecs
Expand Up @@ -317,6 +317,8 @@ core/string/upcase_spec

core/symbol/to_proc_spec

core/struct/each_pair_spec
core/struct/each_spec
core/struct/initialize_spec
core/struct/new_spec

Expand Down

0 comments on commit 6c29774

Please sign in to comment.