Permalink
Browse files

document Array#append and Array#prepend methods in AS guide

  • Loading branch information...
1 parent ebf0cc4 commit f3f5a8f0efb3000b35471777137aadfe1d30a20b @vijaydev vijaydev committed with fxn Aug 16, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 railties/guides/source/active_support_core_extensions.textile
@@ -2067,6 +2067,30 @@ shape_types = [Circle, Square, Triangle].sample(2)
NOTE: Defined in +active_support/core_ext/array/random_access.rb+.
+h4. Adding Elements
+
+h5. +prepend+
+
+This method is an alias of <tt>Array#unshift</tt>.
+
+<ruby>
+%w(a b c d).prepend('e') # => %w(e a b c d)
+[].prepend(10) # => [10]
+</ruby>
+
+NOTE: Defined in +active_support/core_ext/array/prepend_and_append.rb+.
+
+h5. +append+
+
+This method is an alias of <tt>Array#<<</tt>.
+
+<ruby>
+%w(a b c d).append('e') # => %w(a b c d e)
+[].append([1,2]) # => [[1,2]]
+</ruby>
+
+NOTE: Defined in +active_support/core_ext/array/prepend_and_append.rb+.
+
h4. Options Extraction
When the last argument in a method call is a hash, except perhaps for a +&block+ argument, Ruby allows you to omit the brackets:

0 comments on commit f3f5a8f

Please sign in to comment.