Sha256: 3cb4e9bdc41cf6e2399f136f8ea61cd58226f862889a48f4fe48f2477ee966cb

Contents?: true

Size: 342 Bytes

Versions: 2

Compression:

Stored size: 342 Bytes

Contents

require 'facets/ruby' #for Binding#eval

class Binding

  # Returns the value of some variable.
  #
  #   a = 2
  #   binding["a"]  #=> 2
  #
  def []( x )
    eval( x.to_s )
  end

  # Set the value of a local variable.
  #
  #   binding["a"] = 4
  #   a  #=> 4
  #
  def []=( l, v )
    eval( "lambda {|v| #{l} = v}").call( v )
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facets-2.4.0 lib/facets/binding/opvars.rb
facets-2.4.1 lib/facets/binding/opvars.rb