# File lib/pry/core_extensions.rb, line 47
  def __binding__
    # When you're cd'd into a class, methods you define should be added to it.
    if is_a?(Module)
      # class_eval sets both self and the default definee to this class.
      return class_eval "binding"
    end

    unless respond_to?(:__pry__)
      binding_impl_method = ["# Get a binding with 'self' set to self, and no locals.\n#\n# The default definee is determined by the context in which the\n# definition is eval'd.\n#\n# Please don't call this method directly, see {__binding__}.\n#\n# @return [Binding]\ndef __pry__\nbinding\nend\n", __FILE__, __LINE__ + 1]

      # The easiest way to check whether an object has a working singleton class
      # is to try and define a method on it. (just checking for the presence of
      # the singleton class gives false positives for `true` and `false`).
      # __pry__ is just the closest method we have to hand, and using
      # it has the nice property that we can memoize this check.
      begin
        # instance_eval sets the default definee to the object's singleton class
        instance_eval(*binding_impl_method)

      # If we can't define methods on the Object's singleton_class. Then we fall
      # back to setting the default definee to be the Object's class. That seems
      # nicer than having a REPL in which you can't define methods.
      rescue TypeError
        # class_eval sets the default definee to self.class
        self.class.class_eval(*binding_impl_method)
      end
    end

    __pry__
  end