summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authordavidflanagan <davidflanagan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-08 08:12:59 +0000
committerdavidflanagan <davidflanagan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-08 08:12:59 +0000
commit68ddfec346331004e4b4a5374ee4e60c756d7d5c (patch)
tree42513003bbd5d173e3b9fd17f596420e2202d377 /object.c
parent453889cf0ccc2d5676f49893e670fc611e4ae08c (diff)
* object.c: improve docs for Object.tap
* ChangeLog: fix bogus dates on my previous entries git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/object.c b/object.c
index 660c9e1fe1..5bb9a7cd03 100644
--- a/object.c
+++ b/object.c
@@ -448,9 +448,15 @@ rb_obj_is_kind_of(VALUE obj, VALUE c)
* call-seq:
* obj.tap{|x|...} => obj
*
- * Returns the receiver after executing the block given. Its main
- * purpose is to be inseted in the method chain.
- *
+ * Yields <code>x</code> to the block, and then returns <code>x</code>.
+ * The primary purpose of this method is to "tap into" a method chain,
+ * in order to perform operations on intermediate results within the chain.
+ *
+ * (1..10) .tap {|x| puts "original: #{x.inspect}"}
+ * .to_a .tap {|x| puts "array: #{x.inspect}"}
+ * .select {|x| x%2==0} .tap {|x| puts "evens: #{x.inspect}"}
+ * .map { |x| x*x } .tap {|x| puts "squares: #{x.inspect}"}
+ *
*/
VALUE