diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-03 22:35:49 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-03 22:35:49 +0000 |
commit | cb014763c6c38e282f6f4528f8104ed9048fe4b8 (patch) | |
tree | fafff78c5d1b61e047855506b8b985f0cb88ee78 | |
parent | aec0f808bc79c6964632cf1385bf8c61888b66fd (diff) | |
download | ruby-cb014763c6c38e282f6f4528f8104ed9048fe4b8.tar.gz |
* array.c (rb_ary_initialize): Add output for examples. Patch by
Jonathan Mukai. [Ruby 1.9 - Bug #5216]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | array.c | 21 |
2 files changed, 16 insertions, 10 deletions
@@ -1,3 +1,8 @@ +Tue Oct 4 07:35:23 2011 Eric Hodel <drbrain@segment7.net> + + * array.c (rb_ary_initialize): Add output for examples. Patch by + Jonathan Mukai. [Ruby 1.9 - Bug #5216] + Tue Oct 4 07:30:50 2011 Eric Hodel <drbrain@segment7.net> * array.c (rb_ary_s_create): Add example results for Array::[]. Patch @@ -516,26 +516,27 @@ rb_ary_s_try_convert(VALUE dummy, VALUE ary) * calculated by passing the element's index to the given block and * storing the return value. * - * Array.new - * Array.new(2) - * Array.new(5, "A") + * Array.new # => [] (empty array) + * Array.new(2) # => [nil,nil] + * Array.new(5, "A") # => ["A", "A", "A", "A", "A"] + * Array.new(5) {|i| i.to_s } # => ["0", "1", "2", "3", "4"] * * # only one copy of the object is created - * a = Array.new(2, Hash.new) + * a = Array.new(2, Hash.new) #=> [{}, {}] * a[0]['cat'] = 'feline' - * a + * a # => [{"cat"=>"feline"}, {"cat"=>"feline"}] * a[1]['cat'] = 'Felix' - * a + * a # => [{"cat"=>"Felix"}, {"cat"=>"Felix"}] * * # here multiple copies are created - * a = Array.new(2) { Hash.new } + * a = Array.new(2) { Hash.new } # => [{}, {}] * a[0]['cat'] = 'feline' - * a + * a # => [{"cat"=>"feline"}, {}] * * squares = Array.new(5) {|i| i*i} - * squares + * squares # => [0, 1, 4, 9, 16] * - * copy = Array.new(squares) + * copy = Array.new(squares) # => [0, 1, 4, 9, 16] */ static VALUE |