Characters are just a special type of string that is more efficient for the runtime environment. It. They are not methods or variables or anything like that.
When you execute A.send(:test) , all you do is say, “Hey, A, call a method called“ test. ”You don’t send this method yourself, just a name; this is the logic inside send that is responsible for search for the actual calling method.
The same thing happens when you request a method with A.new.method(:test) . All you go through in the method is the name “test”, not the method defined as “test”. Before method use the name and find the actual method so that it can return it, and this is the return value - the Method object - which you make call on. You cannot make a call on a character like :test , because it's just a name.
Mark reed
source share