to my dismay
def xxx... end
is *not* a closure
while
define_method :xxx is
IOW
h is just not visible in def while it would if you define gethas via
define_method
be careful though on the toplevel you cannot use define_method, do
something like
include( Module::new do
h = {}
define_method :xxx do h.tap{ |hh| h[1] = 0 } end
end )
puts xxx
xxx[:a] = 42
puts xxx
oh yes this code is ugly, but I wanted to demonstrate the semantics...
HTH
R.
···
On Sat, Apr 17, 2010 at 7:30 PM, Simbolla Simbolla <vinod236@gmail.com> wrote:
Hi all,
Below is my code
h={}
arr=
def gethash
h[1]=0
return h
end
arr[0]=gethash
puts arr[0].each {|k,v| puts "key #{k} value #{v}"}
--
The best way to predict the future is to invent it.
-- Alan Kay