Permalink
Browse files

AS guide: explains Array.wrap

  • Loading branch information...
1 parent 016905f commit c5c24732a57936fc32f6aa36bb69dc10ab09de5f @fxn fxn committed Aug 24, 2009
Showing with 12 additions and 0 deletions.
  1. +12 −0 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)+

0 comments on commit c5c2473

Please sign in to comment.