From: Patrick Li Date: 2008-08-11T23:57:38+09:00 Subject: Bindings and Context Hi, I'm still really confused about Ruby Closures. At first I thought closures are just blocks who "remember" the context that they were defined in (so that they can refer to local variables and methods) And then I discovered instance_eval (which changes the context that a block is evaluated in). When you use instance_eval you can't call local methods anymore (because, the scope has changed, and those methods aren't local anymore). But how come I can still use local variables? myStr = "myString" o = Object.new o.instance_eval do @str = myStr # <- why does this still work? def method puts @str end end So are local variables sort of an exception to instance_eval? And in the above example, how come it won't work anymore if I change myStr into an instance variable @myStr? Thanks a lot for helping -Patrick PS: Is there a detailed document I can read about OO languages? I come from Java and I'm feeling a little lost amidst all these advanced OO features. -- Posted via http://www.ruby-forum.com/.