From c5c24732a57936fc32f6aa36bb69dc10ab09de5f Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 25 Aug 2009 01:11:26 +0200 Subject: AS guide: explains Array.wrap --- railties/guides/source/active_support_overview.textile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/railties/guides/source/active_support_overview.textile b/railties/guides/source/active_support_overview.textile index fbdc204cee..37491fa1a5 100644 --- a/railties/guides/source/active_support_overview.textile +++ b/railties/guides/source/active_support_overview.textile @@ -817,6 +817,18 @@ You can pick a random element with +rand+: shape_type = [Circle, Square, Triangle].rand +h4. Wrapping + +The class method +Array.wrap+ behaves like the function +Array()+ except that it does not try to call +to_a+ on its argument. That changes the behaviour for enumerables: + + +Array.wrap(:foo => :bar) # => [{:foo => :bar}] +Array(:foo => :bar) # => [[:foo, :bar]] + +Array("foo\nbar") # => ["foo\n", "bar"], in Ruby 1.8 +Array.wrap("foo\nbar") # => ["foo\nbar"] + + h4. Grouping h5. +in_groups_of(number, fill_with = nil)+ -- cgit v1.2.3