Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 824cb8ec4647
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fad767ceec83
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Sep 4, 2016

  1. Copy the full SHA
    c0debf9 View commit details
  2. Merge pull request #3248 from will/uintarraynew

    Array.new(size, &block) accepts UInt32, other Ints
    Ary Borenszweig authored Sep 4, 2016
    Copy the full SHA
    fad767c View commit details
Showing with 4 additions and 1 deletion.
  1. +3 −0 spec/std/array_spec.cr
  2. +1 −1 src/array.cr
3 changes: 3 additions & 0 deletions spec/std/array_spec.cr
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@ describe "Array" do
it "creates with default value in block" do
ary = Array.new(5) { |i| i * 2 }
ary.should eq([0, 2, 4, 6, 8])

ary = Array.new(5_u32) { |i| i * 2 }
ary.should eq([0, 2, 4, 6, 8])
end

it "raises on negative count" do
2 changes: 1 addition & 1 deletion src/array.cr
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ class Array(T)
# ```
def self.new(size : Int, &block : Int32 -> T)
Array(T).build(size) do |buffer|
size.times do |i|
size.to_i.times do |i|
buffer[i] = yield i
end
size