Class: Binding
- Inherits:
-
Object
- Object
- Binding
- Defined in:
- lib/ragtag/core_ext/opvars.rb
Instance Method Summary collapse
-
#[](x) ⇒ Object
Returns the value of some variable.
-
#[]=(l, v) ⇒ Object
Set the value of a local variable.
Instance Method Details
#[](x) ⇒ Object
Returns the value of some variable.
a = 2
binding["a"] #=> 2
10 11 12 |
# File 'lib/ragtag/core_ext/opvars.rb', line 10 def []( x ) eval( x.to_s ) end |
#[]=(l, v) ⇒ Object
Set the value of a local variable.
binding["a"] = 4
a #=> 4
19 20 21 |
# File 'lib/ragtag/core_ext/opvars.rb', line 19 def []=( l, v ) eval( "lambda {|v| #{l} = v}").call( v ) end |