Sha256: 1ed745de40c1cf6a4af578f3d016d4fdea214dd15a886dbfb96969b07a45e4e5

Contents?: true

Size: 721 Bytes

Versions: 1

Compression:

Stored size: 721 Bytes

Contents

require 'nano/binding/eval'
require 'nano/binding/op_fetch'

class Binding

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

end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCBinding < Test::Unit::TestCase

    def setup
      a = 1
      b = 2
      x = "hello"
      # the line number must be updated if it moves
      @bind = binding; @this_line_no = 25
    end

    def test_op_store
      assert_nothing_raised{ @bind["x"] = "goodbye" }
      assert_equal( "goodbye", @bind["x"] )
    end

  end

=end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-0.9.0 lib/nano/binding/op_store.rb