From: Tarek Other Date: 2008-11-13T15:59:44+09:00 Subject: Re: Issue with block and getting to local variables Hi and thanks to all for the help. Can someone explain why this doesnt work def foo x = 5 yield end foo{puts x} Q1) The only way to get it to work is to pass x into it when calling the yield. Why is that, according to above the block does/should have access to it because it is being called withing the scope of the variable Q2) This is ultimately what I want to do (psuedo code below): def my_function(&block) x = 5 s = 15 block.call end my_block = lamda{ puts "#{s+x}" } my_function(&my_block) But it complains about not knowing what s and x are, ie out of scope. Why and how can this be resolved? -- Posted via http://www.ruby-forum.com/.