[ruby-core:102157] [Ruby master Bug#17559] Conflict with BasicSocket#send and Object#send
From:
nobu@...
Date:
2021-01-19 08:38:33 UTC
List:
ruby-core #102157
Issue #17559 has been updated by nobu (Nobuyoshi Nakada).
Status changed from Open to Closed
Description updated
`Object#__send__`
----------------------------------------
Bug #17559: Conflict with BasicSocket#send and Object#send
https://bugs.ruby-lang.org/issues/17559#change-90008
* Author: sergioro (Sergio Romero)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
`Object#send` can be used in most objects like:
```
's'.send :class
=> String
```
But `BasicSocket` objects call `BasicSocket#send` instead of `Object#send`:
```
TCPSocket('example.com', 'echo').send :class
Traceback (most recent call last):
22: from /home/sergioro/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `<main>'
21: from /home/sergioro/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `eval'
20: from /home/sergioro/.rvm/gems/ruby-2.7.0/bin/irb:23:in `<main>'
19: from /home/sergioro/.rvm/gems/ruby-2.7.0/bin/irb:23:in `load'
18: from /home/sergioro/.rvm/gems/ruby-2.7.0/gems/irb-1.3.1/exe/irb:11:in `<top (required)>'
1: from (irb):5:in `<main>'
(irb):5:in `send': wrong number of arguments (given 1, expected 2..3) (ArgumentError)
```
How to call `Object#send` from a BasicSocket object?
**Expected result:**
```
TCPSocket('example.com', 'echo').send :class
=> TCPSocket
```
--
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>