From 2c8938fcba6670f2cb056ec91d631ae0e37ea006 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 24 Dec 2010 00:03:51 +0530 Subject: fixed inject example and some minor edits --- .../guides/source/active_support_core_extensions.textile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index bddff1c987..8821a6e461 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1568,7 +1568,7 @@ The method +tableize+ is +underscore+ followed by +pluralize+. "InvoiceLine".tableize # => "invoice_lines" -As a rule of thumb, +tableize+ returns the table name that corresponds to a given model for simple cases. The actual implementation in Active Record is not straight +tableize+ indeed, because it also demodulizes de class name and checks a few options that may affect the returned string. +As a rule of thumb, +tableize+ returns the table name that corresponds to a given model for simple cases. The actual implementation in Active Record is not straight +tableize+ indeed, because it also demodulizes the class name and checks a few options that may affect the returned string. NOTE: Defined in +active_support/core_ext/string/inflections.rb+. @@ -1868,7 +1868,7 @@ The sum of an empty collection is zero by default, but this is customizable: [].sum(1) # => 1 -If a block is given +sum+ becomes an iterator that yields the elements of the collection and sums the returned values: +If a block is given, +sum+ becomes an iterator that yields the elements of the collection and sums the returned values: (1..5).sum {|n| n * 2 } # => 30 @@ -1896,8 +1896,8 @@ h4. +each_with_object+ The +inject+ method offers iteration with an accumulator: -[2, 3, 4].inject(1) {|acc, i| product*i } # => 24 - +[2, 3, 4].inject(1) {|product, i| product*i } # => 24 + 1+: <% end %> -If an optional block is given +many?+ only takes into account those elements that return true: +If an optional block is given, +many?+ only takes into account those elements that return true: @see_more = videos.many? {|video| video.category == params[:category]} @@ -1952,7 +1952,7 @@ NOTE: Defined in +active_support/core_ext/enumerable.rb+. h4. +exclude?+ -The predicate +exclude?+ tests whether a given object does *not* belong to the collection. It is the negation of the builtin +include?+: +The predicate +exclude?+ tests whether a given object does *not* belong to the collection. It is the negation of the built-in +include?+: to_visit << node if visited.exclude?(node) -- cgit v1.2.3