From: William Djaja Tjokroaminata Date: 2002-04-13T01:38:05+09:00 Subject: Re: How to Make a Method Ineffective Efficiently? I have implemented the construct using the block, which seems the to be the best solution for now based on the suggestions. However, although this may seem sound from the execution time point of view, does this block construct consumes a lot of memory? I will have thousands of the construct, such as debug () {[a, b, c, d, e, f, g, h]} # line 1 .... debug () {[i, j]} # line 2 .... debug () {[x, y, z, a, b, c, g, k, z, l, t, p]} # line 10,000 Does Ruby creates memory space for each block? With function call, I don't think Ruby will create any additional space, only enough to hold the variables themselves, which is only a, b, ..., z: debug (a, b, c, d, e, f, g, h) .... debug (i, j) .... debug (x, y, z, a, b, c, g, k, z, l, t, p) Regards, Bill ============================================================================ David Alan Black wrote: >> def debug () >> if @debugging >> data = yield >> puts "data = #{data}" >> .... # do processing with data[0], data[1], ..., data[n] >> end >> end >> >> debug () {return a, b, c} >> >> This does not work! > Yeah, I've been bitten by that on occasion. It returns from the > yielder, not the yieldee. You'd need to just put the value you > want: > debug { [a,b,c] } > David