From bd4800d614eb7060354a6f9fd8a749a7e7f046a8 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Tue, 16 Aug 2011 14:57:36 +0530 Subject: document Array#append and Array#prepend methods in AS guide --- .../source/active_support_core_extensions.textile | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'railties/guides/source/active_support_core_extensions.textile') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index a672b17e4a..e1fa374aca 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -2069,6 +2069,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 Array#unshift. + + +%w(a b c d).prepend('e') # => %w(e a b c d) +[].prepend(10) # => [10] + + +NOTE: Defined in +active_support/core_ext/array/prepend_and_append.rb+. + +h5. +append+ + +This method is an alias of Array#<<. + + +%w(a b c d).append('e') # => %w(a b c d e) +[].append([1,2]) # => [[1,2]] + + +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: -- cgit v1.2.3