[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

using Proc and yield

Alber Eric

12/15/2006 3:05:00 PM

hi !

I'm new to ruby and I'm currently testing the language. So I know I can
write this:

def hello()
yield "hello world"
end

hello { |i| puts i }

This prints "hello world" on the console, cool.

Now I wonder if the following code is valid :

p = Proc.new { yield "hello world" }

p.call { |i| puts i }

when I execute this I get the following error :
LocalJumpError: no block given
from (irb):83
from (irb):85:in `call'
from (irb):85
from :0


I belived Proc.call was equivalent to a standard method call, it seems
I'm wrong :). Did I misunderstand something? Can someone tell me where I
made a mistake?

Thank you

--
Posted via http://www.ruby-....