method

local_variable_defined?

Importance_1
v2_1_10 - Show latest stable - 0 notes - Class: Binding
local_variable_defined?(p1) public

Returns a true if a local variable symbol exists.

def foo
  a = 1
  binding.local_variable_defined?(:a) #=> true
  binding.local_variable_defined?(:b) #=> false
end

This method is short version of the following code.

binding.eval("defined?(#{symbol}) == 'local-variable'")
Show source
Register or log in to add new notes.