From: Robert Klemme Date: 2003-02-03T18:13:15+09:00 Subject: Re: Local variables & blocks "Yukihiro Matsumoto" schrieb im Newsbeitrag news:1044259248.089322.399.nullmailer@picachu.netlab.jp... > Hi, > > In message "Re: Local variables & blocks" > on 03/02/03, "Robert Klemme" writes: > > |Ok, then I did not get it right. I'll ask the other way round. What is the > |proposed behavior of this: > | > |def blocktest(*args) > | args.each do |arg| > | foo = "yes" > | end > | > | p foo > |end > | > |blocktest(1,2,3) > |blocktest() > | > | > |If I do understand the thread correctly, 'foo' will not be local to the > |block - just 'arg' will. So 'foo' will always be defined in 'blocktest()'. > > You're correct. Thank you for taking time to understand me. You're welcome. Thank you for taking the time to help me get there! I just wonder what the second invocation of blocktest() will print. Since there is no iteration, no assignment to 'foo' will have taken place. Is this an error or will 'foo' be initialized with 'nil'? I guess 'nil' initialization will be more reasonable because it saves an additional test. Kind regards robert