mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
object.c: improve docs
* object.c: [DOC] add an example for Object#yield_self that better illustrates its purpose; other small improvements. Reported by Vitaly Tatarintsev (ck3g). Patch by Marcus Stollsteimer. [Fix GH-1637] * object.c: [DOC] improve docs for Object#{itself,tap}. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e4cc791f87
commit
8bce215fa2
1 changed files with 13 additions and 12 deletions
13
object.c
13
object.c
|
@ -493,11 +493,11 @@ rb_obj_dup(VALUE obj)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.itself -> an_object
|
||||
* obj.itself -> obj
|
||||
*
|
||||
* Returns <i>obj</i>.
|
||||
* Returns the receiver.
|
||||
*
|
||||
* string = 'my string' #=> "my string"
|
||||
* string = "my string"
|
||||
* string.itself.object_id == string.object_id #=> true
|
||||
*
|
||||
*/
|
||||
|
@ -516,11 +516,12 @@ rb_obj_size(VALUE self, VALUE args, VALUE obj)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.yield_self {|_obj|...} -> an_object
|
||||
* obj.yield_self {|x| block } -> an_object
|
||||
*
|
||||
* Yields <i>obj</i> and returns the result.
|
||||
* Yields self to the block and returns the result of the block.
|
||||
*
|
||||
* 'my string'.yield_self {|s|s.upcase} #=> "MY STRING"
|
||||
* "my string".yield_self {|s| s.upcase } #=> "MY STRING"
|
||||
* 3.next.yield_self {|x| x**x }.to_s #=> "256"
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue