Flowdock
method

local_variable_defined?

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

Returns 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 the short version of the following code:

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