Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
Eval and block problems
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Brian Schröder, post: 4485796"] Please help me to wrap my mind around this. I want to achieve the following= : class A def self.def_me(cmd, &block) eval %( def #{cmd}() do things # CALL BLOCK end ) end def_me("foo") do # access instance of A end end A.new.foo and have the block from the dynamically created method foo be evaluated in the binding of the instance of A. I'm sure this is possible, but I've never really grocked eval, instance_eval and class_eval. best regards, Brian [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Eval and block problems
Top