diff options
-rw-r--r-- | railties/guides/source/active_support_overview.textile | 18 |
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+ |