I
Imobach González Sosa
Hi all,
I'm re-joining to the ruby-talk mailing list and this time I hope I
can get some spare time to read some threads
BTW, here's my first question. It is about procs and scopes:
my_proc =3D lambda { |arg1| puts arg1; puts user }
AFAIK, arg1 is passed as a parameter (ie. when calling Proc#call) and user =
is
taken from the scope where my_proc is declared.
So, my question is: how could I do that 'user' was deferred until proc
is called?
def call_my_proc(&some_proc)
user =3D 'me'
some_proc.call("Hi, it's")
end
my_proc =3D lambda { |arg1| puts arg1; puts user }
call_my_proc(&my_proc) # "Hi, it's me"
I think I could do using eval with a string, but I'd like to solve in
block-like form.
Is that possible? Any ideas?
Thank you in advance.
--=20
Imobach Gonz=E1lez Sosa
imobachgs at gmail dot com
I'm re-joining to the ruby-talk mailing list and this time I hope I
can get some spare time to read some threads
BTW, here's my first question. It is about procs and scopes:
my_proc =3D lambda { |arg1| puts arg1; puts user }
AFAIK, arg1 is passed as a parameter (ie. when calling Proc#call) and user =
is
taken from the scope where my_proc is declared.
So, my question is: how could I do that 'user' was deferred until proc
is called?
def call_my_proc(&some_proc)
user =3D 'me'
some_proc.call("Hi, it's")
end
my_proc =3D lambda { |arg1| puts arg1; puts user }
call_my_proc(&my_proc) # "Hi, it's me"
I think I could do using eval with a string, but I'd like to solve in
block-like form.
Is that possible? Any ideas?
Thank you in advance.
--=20
Imobach Gonz=E1lez Sosa
imobachgs at gmail dot com