kernel/delta/array.rb
# Returns a new Array populated from the elements in
# self corresponding to the given selector(s.) The
# arguments may be one or more integer indices or
# Ranges.
Returns a new Array populated from the elements in
self corresponding to the given selector(s.) The
arguments may be one or more integer indices or
Ranges.
Returns a new Array populated from the elements in self corresponding to the given selector ( s . ) The arguments may be one or more integer indices or Ranges .
def values_at(*args)
    out = []
    args.each { |elem|
      if elem.kind_of? Range
        finish = elem.last
        start = elem.first
        start, finish = Type.coerce_to(start, Fixnum, :to_int), Type.coerce_to(finish, Fixnum, :to_int)
        start += @total if start < 0
        next if start < 0
        finish += @total if finish < 0
        finish -= 1 if elem.exclude_end?
        finish = @total unless finish < @total
        next if finish < start
        start.upto(finish) { |i| out << at(i) }
      else
        i = Type.coerce_to elem, Fixnum, :to_int
        out << at(i)
      end
    }
    out
  end
def values_at ( * args ) out = [ ] args . each { | elem | if elem . kind_of? Range finish = elem . last start = elem . first start , finish = Type . coerce_to ( start , Fixnum , :to_int ) , Type . coerce_to ( finish , Fixnum , :to_int ) start += @total if start < 0 next if start < 0 finish += @total if finish < 0 finish -= 1 if elem . exclude_end? finish = @total unless finish < @total next if finish < start start . upto ( finish ) { | i | out << at ( i ) } else i = Type . coerce_to elem , Fixnum , :to_int out << at ( i ) end } out end
Returns a new Array populated from the elements in
self corresponding to the given selector(s.) The
arguments may be one or more integer indices or
Ranges.
Returns a new Array populated from the elements in self corresponding to the given selector ( s . ) The arguments may be one or more integer indices or Ranges .
# Cannot use #[] because of subtly different errors
args
<not_specific>