*a…b means, it will apply the method Enumerable#to_a method on the
Baiscally [*2…6] is same as (2…6).to_a.
Now I wanted to confirm myself, if I am correct it or not. Thus I did
from the below code.
trace = TracePoint.new do |tp|
p [tp.lineno, tp.event, tp.defined_class,tp.method_id]
>> [5, :b_call, nil, nil]
>> [6, :line, nil, nil]
>> [6, :c_call, Enumerable, :to_a]
>> [6, :c_call, Range, :each]
>> [6, :c_return, Range, :each]
>> [6, :c_return, Enumerable, :to_a]
>> [7, :b_return, nil, nil]
The code is showing yes, #to_a method got called. But don’t know why
Range#each method invoked. Can anybody give me some light on this ?
#each involved in this range object destruction
Debugging is twice as hard as writing the code in the first place.
if you write the code as cleverly as possible, you are, by definition,
smart enough to debug it.