You know what your completely right. The block only will take what the
yield method returns to it. So apparently when instantiating an array
with that first argument setting a size limit for array, the
constructor contains a yield method which yields each iteration of
that size limit. And then the
thanks for response but that was just an example and not really what
my question was about.
Perhaps this is a better example:
>> Array.new(10) do |id|
?> "'#{(id + 1).to_s.rjust(2,"0")}'"
>> end
=> ["'01'", "'02'", "'03'", "'04'", "'05'", "'06'", "'07'", "'08'",
"'09'", "'10'"]
Why is "id" not
2 matches
Mail list logo