diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2011-08-16 14:57:36 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2011-08-16 14:57:36 +0530 |
commit | bd4800d614eb7060354a6f9fd8a749a7e7f046a8 (patch) | |
tree | 0032cb835ccd891fda030fe400020afb844e1467 | |
parent | 308595739c32609ac5b167ecdc6cb6cb4ec6c81f (diff) | |
download | rails-bd4800d614eb7060354a6f9fd8a749a7e7f046a8.tar.gz rails-bd4800d614eb7060354a6f9fd8a749a7e7f046a8.tar.bz2 rails-bd4800d614eb7060354a6f9fd8a749a7e7f046a8.zip |
document Array#append and Array#prepend methods in AS guide
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 24 |
1 files changed, 24 insertions, 0 deletions
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 <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: |