概要
Array adding
詳細
Array adding について
サンプル
# encoding: utf-8 require 'active_support/core_ext/array/access' require 'tbpgr_utils' I18n.enforce_available_locales = true ary = [*1..5] bulk_puts_eval binding, <<-EOS ary.prepend 0 ary.append 6 [].prepend 0 [].append 0 EOS __END__ ・下記はTbpgrUtils gemの機能 bulk_puts_eval https://rubygems.org/gems/tbpgr_utils https://github.com/tbpgr/tbpgr_utils
出力
ary.prepend 0 # => [0, 1, 2, 3, 4, 5] ary.append 6 # => [0, 1, 2, 3, 4, 5, 6] [].prepend 0 # => [0] [].append 0 # => [0]