Skip to content

Commit

Permalink
Initial implementation of Enumerable#zip
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Dec 14, 2013
1 parent 53fe56b commit 6b27223
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -87,7 +87,7 @@
self. Add `Struct.[]` as synonym for `Struct.new`.

* Implemented some `Enumerable` methods: `#collect_concat`, `#flat_map`,
`#reject`, `#reverse_each` and `#partition`.
`#reject`, `#reverse_each`, `#partition` and `#zip`.

## 0.5.5 2013-11-25

Expand Down
5 changes: 2 additions & 3 deletions opal/corelib/enumerable.rb
Expand Up @@ -1126,8 +1126,7 @@ def take_while(&block)

alias to_a entries

def zip(*lists, &block)
raise NotImplementedError
def zip(*others, &block)
to_a.zip(*others)
end
end

8 changes: 3 additions & 5 deletions spec/opal/filters/bugs/enumerable.rb
Expand Up @@ -58,10 +58,8 @@
fails "Enumerable#sort yields elements to the provided block"
fails "Enumerable#sort sorts by the natural order as defined by <=> "

fails "Enumerable#zip gathers whole arrays as elements when each yields multiple"
fails "Enumerable#zip converts arguments to enums using #to_enum"
fails "Enumerable#zip converts arguments to arrays using #to_ary"
fails "Enumerable#zip fills resulting array with nils if an argument array is too short"
fails "Enumerable#zip passes each element of the result array to a block and return nil if a block is given"
fails "Enumerable#zip combines each element of the receiver with the element of the same index in arrays given as arguments"
fails "Enumerable#zip converts arguments to arrays using #to_ary"
fails "Enumerable#zip converts arguments to enums using #to_enum"
fails "Enumerable#zip gathers whole arrays as elements when each yields multiple"
end

0 comments on commit 6b27223

Please sign in to comment.