kernel/common/array.rb
# Generates a string from converting all elements of
# the Array to strings, inserting a separator between
# each. The separator defaults to $,. Detects recursive
# Arrays.
Generates a string from converting all elements of
the Array to strings, inserting a separator between
each. The separator defaults to $,. Detects recursive
Arrays.
Generates a string from converting all elements of the Array to strings inserting a separator between each . The separator defaults to $ . Detects recursive Arrays .
def join(sep = nil, method = :to_s)
    return "" if @total == 0
    sep ||= $,
    begin
      sep = sep.to_str
    rescue NoMethodError
      raise TypeError, "Cannot convert #{sep.inspect} to str"
    end
    out = ""
    out.taint if sep.tainted? or self.tainted?
    i = 0
    while(i < @total)
      elem = at(i)
      out.append sep unless (i == 0)
      if elem.kind_of?(Array)
        if RecursionGuard.inspecting?(elem)
          out.append "[...]"
        else
          RecursionGuard.inspect(self) do
            out.append elem.join(sep, method)
          end
        end
      else
        out.append elem.to_s
        out.taint if elem.tainted? and not out.tainted?
      end
      i += 1
    end
    out
  end
def join ( sep = nil , method = :to_s ) return "" if @total == 0 sep ||= $, begin sep = sep . to_str rescue NoMethodError raise TypeError , "Cannot convert #{sep.inspect} to str" end out = "" out . taint if sep . tainted? or self . tainted? i = 0 while ( i < @total ) elem = at ( i ) out . append sep unless ( i == 0 ) if elem . kind_of? ( Array ) if RecursionGuard . inspecting? ( elem ) out . append "[...]" else RecursionGuard . inspect ( self ) do out . append elem . join ( sep , method ) end end else out . append elem . to_s out . taint if elem . tainted? and not out . tainted? end i += 1 end out end
Generates a string from converting all elements of
the Array to strings, inserting a separator between
each.
Generates a string from converting all elements of the Array to strings inserting a separator between each .
# HACK use __send__ # out << elem.__send__(method)
sep
<not_specific>
method
<not_specific>