Issue #11980 has been updated by Sumit Mahamuni.


It's not really a bug. 

When you define following method. It is added on Object class. And any class which inherits from Object class will have following method. 

You can try calling following method on any class which inherits Object class, you should get same output. 

```
def a
  "foo"
end
```

----------------------------------------
Bug #11980: External methods are appearing as instance methods for String
https://bugs.ruby-lang.org/issues/11980#change-56100

* Author: Daniel P. Clark
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.3.0
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
It appears we're having methods creep into the String scope.

~~~ruby
"".methods.count
# => 170

defined? "".a
# => nil

def a
 "foo"
end

"".methods.count
# => 171

defined? "".a
# => "method"

"bar".a
# => "foo"
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>