Skip to content

Instantly share code, notes, and snippets.

@nurse nurse/result.sh
Last active Oct 24, 2016

Embed
What would you like to do?
% ruby --disable-gems test.rb
{:T_HASH=>1, :T_DATA=>2}
{:T_ARRAY=>1, :T_HASH=>1, :T_DATA=>1}
def myroot2(&block)
myfunc2(Time.now, {"a"=>1, "b"=>2}, &block)
end
def myfunc2(time, record)
yield time, record
end
def myroot1
time, record = myfunc1(Time.now, {"a"=>1, "b"=>2})
yield time, record
end
def myfunc1(time, record)
return time, record
end
h0={}
h1={}
h2={}
ObjectSpace.count_objects(h0)
GC.disable
ObjectSpace.count_objects(h0)
#p :block_and_yield
myroot2{|t,r| t; r; 1}
ObjectSpace.count_objects(h1)
#p :multi_value_return
myroot1{|t,r| t; r; 1}
ObjectSpace.count_objects(h2)
p h1.keys.map{|k|[k,h1[k]-h0[k]]}.select{|(a,b)|b>0}.to_h
p h1.keys.map{|k|[k,h2[k]-h1[k]]}.select{|(a,b)|b>0}.to_h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.