Given that dynamic modifications such as method superscripts are common to see in Ruby, the Object#__send__
and Object#send
is a way to protect objects against overwriting. The __send__
serves as an internal alias, which you can use if your object has some resetting of send
. For example:
"hello world".send :upcase
=> "HELLO WORLD"
module EvilSend
def send(foo)
"Não foi dessa vez..."
end
end
String.include EvilSend
"hello world".send :upcase
=> "Não foi dessa vez"
"hello world".__send__ :upcase
=> "HELLO WORLD"
Note that there is no Ruby Warning on the superscript of this method. That’s why there is __send__
. The method that CANNOT be overwritten under any circumstances is the __send__
. If you try, Ruby throws a warning.
Warning: Redefining '__send__
' may Serious problems
I think you have a similar question at the international forum, see if it helps you: https://stackoverflow.com/questions/4658269/ruby-send-vs-send
– Christian Jorge