From: Derek Michael Date: 2009-12-19T07:19:55+09:00 Subject: Re: Newbie Question: Blocks and Parameters Thanks guys. I think I'm slowly wrapping my head around this. Now sort of in the lines of the callback you mentioned, I started reading about the & operator and being able to convert blocks to procs and vice versa. Here is an example of the code I was reviewing: puts "----Define a method which takes block as a Proc object argument" def my_method(count, &my_block) value = 1 # Execute the block "count" times while updating the vlaue i 1.upto(count) do |i| value = value * i my_block.call(i, value) end end puts "----Invoke the method passing a code block" my_method(5) {|i, result| puts "my_method(#{i}) = #{result} "} So in this case, the variable 'i' gets the value of variable 'count' assigned to it when executing the upto method which invokes a yield? Am I understanding this correctly? It took me a while looking at that code again, to understand where the 'i' was getting it's value... -- Posted via http://www.ruby-forum.com/.