From: Gennady Date: 2003-07-09T06:22:34+09:00 Subject: Re: Accessing code blocks You can do: block = proc { |arg| puts "Here's the argument: #{arg}" } def f(b,arg) b.call arg end # proc can be passed around, like in: f(block,1) # Here's the argument: 1 f(block,2) # Here's the argument: 1 With this, you cannot print the code given in proc. If you really need to access the source of the code, keep the code in the string and eval to execute it (yack). Gennady. On Tuesday, July 8, 2003, at 02:05 PM, Grzegorz Dostatni wrote: > > Cheers! > > I need to do something silly. I need to access the code block as a > variable (to pass it - without evaluating - to another function). How > can > I do that? > > Is it possible for me to access the "text version of block?" Can I > print > out the code that has been attached to my function instead of executing > it? > > The only functions that work on code block (that I could find) are: > block_given? and yield. Obviously they do not fit the bill... > > Please help. > > Grzegorz Dostatni > > >