aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_support_overview.textile
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2009-07-30 04:13:29 +0200
committerXavier Noria <fxn@hashref.com>2009-07-30 04:13:29 +0200
commit23f5e7e966defaaa1511eca57bd8de47f95cb7d9 (patch)
tree6056dfe264416b5efec5c6e81a57b26382263b81 /railties/guides/source/active_support_overview.textile
parentc783b48a8d71eab34f2b4a120fbeb35361714647 (diff)
downloadrails-23f5e7e966defaaa1511eca57bd8de47f95cb7d9.tar.gz
rails-23f5e7e966defaaa1511eca57bd8de47f95cb7d9.tar.bz2
rails-23f5e7e966defaaa1511eca57bd8de47f95cb7d9.zip
AS guide: explains Symbol#to_proc
Diffstat (limited to 'railties/guides/source/active_support_overview.textile')
-rw-r--r--railties/guides/source/active_support_overview.textile18
1 files changed, 17 insertions, 1 deletions
diff --git a/railties/guides/source/active_support_overview.textile b/railties/guides/source/active_support_overview.textile
index 93c189ddb6..4157694844 100644
--- a/railties/guides/source/active_support_overview.textile
+++ b/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+