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-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
using Proc and yield
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password