Sha256: 2845c40eba056a9847a9d1c5c3838986356be1da6ef6e7874b26c807a3879b32
Contents?: true
Size: 628 Bytes
Versions: 12
Compression:
Stored size: 628 Bytes
Contents
require "spec_helper" describe "Array#fill" do it "returns self" do ary = [1, 2, 3] ary.fill(:a).should equal(ary) end it "is destructive" do ary = [1, 2, 3] ary.fill(:a) ary.should == [:a, :a, :a] end it "replaces all elements in the array with the filler if not given an index nor a length" do ary = ['a', 'b', 'c', 'duh'] ary.fill(8).should == [8, 8, 8, 8] str = "x" ary.fill(str).should == [str, str, str, str] end it "replaces all elements with the value of block (index given to block)" do [nil, nil, nil, nil].fill { |i| i * 2 }.should == [0, 2, 4, 6] end end
Version data entries
12 entries across 12 versions & 1 rubygems