Sha256: 21775deb791fcb37009dc5593e5ec6419aaf12cc11c5d16992288220a6514557

Contents?: true

Size: 606 Bytes

Versions: 23

Compression:

Stored size: 606 Bytes

Contents

describe "Array#zip" do
  it "returns an array of arrays containing corresponding elements of each array" do
    [1, 2, 3, 4].zip(["a", "b", "c", "d", "e"]).should ==
      [[1, "a"], [2, "b"], [3, "c"], [4, "d"]]
  end

  it "fills in missing values with nil" do
    [1, 2, 3, 4, 5].zip(["a", "b", "c", "d"]).should ==
      [[1, "a"], [2, "b"], [3, "c"], [4, "d"], [5, nil]]
  end

  it "calls block if supplied" do
    values = []
    [1, 2, 3, 4].zip(["a", "b", "c", "d", "e"]) { |value|
      values << value
    }.should == nil

    values.should == [[1, "a"], [2, "b"], [3, "c"], [4, "d"]]
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
opal-0.3.41 spec/core/array/zip_spec.rb
opal-0.3.40 spec/core/array/zip_spec.rb
opal-0.3.39 spec/core/array/zip_spec.rb
opal-0.3.38 spec/core/array/zip_spec.rb
opal-0.3.37 spec/core/array/zip_spec.rb
opal-0.3.36 spec/core/array/zip_spec.rb
opal-0.3.35 spec/core/array/zip_spec.rb
opal-0.3.34 spec/core/array/zip_spec.rb
opal-0.3.33 spec/core/array/zip_spec.rb
opal-0.3.32 spec/core/array/zip_spec.rb
opal-0.3.31 spec/core/array/zip_spec.rb
opal-0.3.30 spec/core/array/zip_spec.rb
opal-0.3.29 spec/core/array/zip_spec.rb
opal-0.3.28 spec/core/array/zip_spec.rb
opal-0.3.27 spec/core/array/zip_spec.rb
opal-0.3.26 spec/core/array/zip_spec.rb
opal-0.3.25 spec/core/array/zip_spec.rb
opal-0.3.22 spec/core/array/zip_spec.rb
opal-0.3.21 test/core/array/zip_spec.rb
opal-0.3.20 test/core/array/zip_spec.rb