Skip to content

Commit

Permalink
Make Enumerable#group_by compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Nov 11, 2013
1 parent 570611d commit 1c7a5e3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
4 changes: 2 additions & 2 deletions opal/core/enumerable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def grep(pattern, &block)
def group_by(&block)
return enum_for :group_by unless block_given?

hash = Hash.new { |h, k| h[k] = [] }
hash = Hash.new

%x{
var result;
Expand All @@ -566,7 +566,7 @@ def group_by(&block)
return $breaker;
}
#{hash[`value`] << `param`};
#{(hash[`value`] ||= []) << `param`};
}
self.$each();
Expand Down
3 changes: 0 additions & 3 deletions spec/filters/bugs/enumerable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

fails "Enumerable#grep can use $~ in the block when used with a Regexp"

fails "Enumerable#group_by returns a hash without default_proc"
fails "Enumerable#group_by gathers whole arrays as elements when each yields multiple"

fails "Enumerable#inject returns nil when fails(legacy rubycon)"
fails "Enumerable#inject without inject arguments(legacy rubycon)"

Expand Down

0 comments on commit 1c7a5e3

Please sign in to comment.