mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* array.c: More doc examples for Array#{map|collect}{!} using both forms
* enum.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
919f1438ae
commit
e91ccb6c67
2 changed files with 6 additions and 3 deletions
7
array.c
7
array.c
|
@ -2662,8 +2662,9 @@ rb_ary_sort_by_bang(VALUE ary)
|
|||
* If no block is given, an Enumerator is returned instead.
|
||||
*
|
||||
* a = [ "a", "b", "c", "d" ]
|
||||
* a.map { |x| x + "!" } #=> ["a!", "b!", "c!", "d!"]
|
||||
* a #=> ["a", "b", "c", "d"]
|
||||
* a.collect { |x| x + "!" } #=> ["a!", "b!", "c!", "d!"]
|
||||
* a.map.with_index{ |x, i| x * i } #=> ["", "b", "cc", "ddd"]
|
||||
* a #=> ["a", "b", "c", "d"]
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -2698,6 +2699,8 @@ rb_ary_collect(VALUE ary)
|
|||
* a = [ "a", "b", "c", "d" ]
|
||||
* a.map! {|x| x + "!" }
|
||||
* a #=> [ "a!", "b!", "c!", "d!" ]
|
||||
* a.collect!.with_index {|x, i| x[0...i] }
|
||||
* a #=> ["", "b", "c!", "d!"]
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
|
2
enum.c
2
enum.c
|
@ -420,7 +420,7 @@ collect_all(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
|
|||
*
|
||||
* If no block is given, an enumerator is returned instead.
|
||||
*
|
||||
* (1..4).collect { |i| i*i } #=> [1, 4, 9, 16]
|
||||
* (1..4).map { |i| i*i } #=> [1, 4, 9, 16]
|
||||
* (1..4).collect { "cat" } #=> ["cat", "cat", "cat", "cat"]
|
||||
*
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue