ruby - How do I give one method invoked in a block the ability to see variables set in the context of the calling function? -
I have a module that defines a method, I want to be able to use and get: Essentially, I should be able to reach values in the What is the correct way to turn it off? One way to do this is: - log , which results in a The prefix will add a different method,
: :
Module M DF log (and block) str = "log in:" block.call say end def ( Value) + value and end
M inside a
class block, such as :
Expand square C extension M (say "one" "two"} End
# = & gt; "Login: one" # = & gt; "log in: two"
log in
logs which only call
logging Consequently, I like to avoid example variables, global variables, et.
Module M def log (and R block) str = "log:" block.call (str) say enddef (str, value) extends str + value end end class c {{s | | Say, "one", "two"} end
Comments
Post a Comment