diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-01-29 14:53:38 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-01-29 14:53:38 +0900 |
| commit | 5346bdd76b3946a94efaea96ef10cbdbc5f8251e (patch) | |
| tree | 7abfd66be0f9b4f12b6f896d99cb3041e82175dc /mrbgems/mruby-array-ext | |
| parent | b69bb896fcae64373606172fc43c558f02d4207f (diff) | |
| download | mruby-5346bdd76b3946a94efaea96ef10cbdbc5f8251e.tar.gz mruby-5346bdd76b3946a94efaea96ef10cbdbc5f8251e.zip | |
move range aware aget to array.c from mruby-array-ext gem
Diffstat (limited to 'mrbgems/mruby-array-ext')
| -rw-r--r-- | mrbgems/mruby-array-ext/mrblib/array.rb | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/mrbgems/mruby-array-ext/mrblib/array.rb b/mrbgems/mruby-array-ext/mrblib/array.rb index f8d89dc7b..337cef632 100644 --- a/mrbgems/mruby-array-ext/mrblib/array.rb +++ b/mrbgems/mruby-array-ext/mrblib/array.rb @@ -201,36 +201,4 @@ class Array self.replace(result) end end - - ## - # call-seq: - # ary[rng] -> ary slice - # - # Remeturns a slice of +ary+ according to the Range instance +rng+. - # - # a = [ "a", "b", "c", "d", "e" ] - # a[1] => "b" - # a[1,2] => ["b", "c"] - # a[1..-2] => ["b", "c", "d"] - # - def [](idx, len=nil) - case idx - when Range - if idx.last < 0 then - len = self.length - idx.first + idx.last + 1 - else - len = idx.last - idx.first + 1 - end - return self.slice(idx.first, len) - when Numeric - if len then - return self.slice(idx.to_i, len.to_i) - else - return self.slice(idx.to_i) - end - else - self.slice(idx) - end - end - end |
