diff options
author | Xavier Noria <fxn@hashref.com> | 2009-08-25 01:11:26 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2009-08-25 01:11:26 +0200 |
commit | c5c24732a57936fc32f6aa36bb69dc10ab09de5f (patch) | |
tree | d7b3b6ae925747b578acd1f9b601a23ffc5a8466 /railties/guides | |
parent | 016905f97fd6aa3b8f30298054e6e428cd92dcf0 (diff) | |
download | rails-c5c24732a57936fc32f6aa36bb69dc10ab09de5f.tar.gz rails-c5c24732a57936fc32f6aa36bb69dc10ab09de5f.tar.bz2 rails-c5c24732a57936fc32f6aa36bb69dc10ab09de5f.zip |
AS guide: explains Array.wrap
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/source/active_support_overview.textile | 12 |
1 files changed, 12 insertions, 0 deletions
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 </ruby> +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: + +<ruby> +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"] +</ruby> + h4. Grouping h5. +in_groups_of(number, fill_with = nil)+ |