Permalink
Browse files

AS guide: explains Symbol#to_proc

  • Loading branch information...
1 parent c783b48 commit 23f5e7e966defaaa1511eca57bd8de47f95cb7d9 @fxn fxn committed Jul 30, 2009
Showing with 17 additions and 1 deletion.
  1. +17 −1 railties/guides/source/active_support_overview.textile
@@ -610,7 +610,23 @@ h3. Extensions to +FalseClass+
h3. Extensions to +Symbol+
-...
+h4. +to_proc+
+
+The method +to_proc+ turns a symbol into a Proc object so that for example
+
+<ruby>
+emails = users.map {|u| u.email}
+</ruby>
+
+can be written as
+
+<ruby>
+emails = users.map(&:email)
+</ruby>
+
+TIP: If the method that receives the Proc yields more than one value to it the rest are considered to be arguments of the method call.
+
+Symbols from Ruby 1.8.7 on respond to +to_proc+, and Active Support defines it for previous versions.
h3. Extensions to +String+

0 comments on commit 23f5e7e

Please sign in to comment.