From: Trans Date: 2005-09-26T13:41:42+09:00 Subject: How each class splats First I'll just ask it there's a way to do this WITHOUT redefining #each in Array. class A def initialize(i,v) @i,@v=i,v end end arrayofA = [ A.new(:a,1), A.new(:b,2) ] arrayofA.each { |e| p e } => # # arrayofA.each { |i,v| p i,v } => :a 1 :b 2 If thsi is not possible, what do people think of allowing a class to define a #splat method to determine how it will splat into an each block (and perhaps other things). class A def initialize(i,v) @i,@v=i,v end def splat( arity ) case arity when 1 then self when 2 then [@i,@v] else [@i,@v].concat( [nil]*(arity-2) ) end end end Or something to that effect. Thanks, T.