>>>>> "d" == dave rose <bitdoger2 / yahoo.com> writes:

d> Please give an example where the arraymine (or any other example) join 
d> WOULD recursively recall itself so that i can see the difference.... 

 Well, here a recursive function

moulon% cat b.rb
#!/usr/bin/ruby
class ArrayMine < Array
   # Build a string from this array, formatting each entry
   # then joining them together.
   def join( sep = $,, format = "%s" )
      x = collect {|item| sprintf( format, item ) }
      y = ArrayMine.new(x)
      y.join(sep)
   end
end

p ArrayMine[1,2].join
moulon%

 First it create an Array `x'
 Create an object ArrayMine `y'
 Then call #join for `y' (i.e. ArrayMine#join)

moulon% ./b.rb
./b.rb:6:in `join': stack level too deep (SystemStackError)
	from ./b.rb:8:in `join'
	from ./b.rb:12
moulon% 

 The original version is


moulon% cat b.rb
#!/usr/bin/ruby
class ArrayMine < Array
   # Build a string from this array, formatting each entry
   # then joining them together.
   def join( sep = $,, format = "%s" )
      x = collect {|item| sprintf( format, item ) }
      x.join(sep)
   end
end

p ArrayMine[1,2].join
moulon% 

 First it create an Array `x'
 Then call #join for `x' (i.e. Array#join)

moulon% ./b.rb
"12"
moulon% 



Guy Decoux