> It's all method calls.
Probably nitpicking, but it's actually all messages. An object might not have a method "foo", but happily respond to the "foo" message.
Re:Ruby 2.2.0-preview1 Released
by dragonwriter on Thursday September 18, 2014 @03:58PM
(#8337273)
Its all method calls. Specifically, its all calls to #send, most of which get relayed to another method (either based on the message name or, if no such method exists, #method_missing.)
Re:Ruby 2.2.0-preview1 Released
by throwaway0010 on Thursday September 18, 2014 @03:45PM
(#8337195)
And the object responds to the "foo" message by calling a method.
The difference is whether we're discussing the invocation or the response. OP's usage of method isn't incorrect in this case if it's discussing the response. It is true that all message responses (including accessors) are implemented using methods.
> It is true that all message responses (including accessors) are implemented using methods.
An object can respond to a message even though it doesn't have a method with that name. A classic example are Rails' dynamic finders:
User.methods.include?(:find_by_name)
=> false
User.respond_to?(:find_by_name)
=> true
Re:Ruby 2.2.0-preview1 Released
by dragonwriter on Thursday September 18, 2014 @04:34PM
(#8337482)
> An object can respond to a message even though it doesn't have a method with that name.
Sure, by using a different method (method_missing); its still all method calls.
Re:Ruby 2.2.0-preview1 Released
by throwaway0010 on Saturday September 20, 2014 @07:14PM
(#8345845)
Yes and the responses are implemented with methods. Always.
I believe he meant local variables (or if he didn't he should have).
Re:Ruby 2.2.0-preview1 Released
by xentronium on Thursday September 18, 2014 @12:44PM
(#8336175)
Well, they sort of do, in the form of instance variables.
Re:Ruby 2.2.0-preview1 Released
by regularfry on Thursday September 18, 2014 @03:31PM
(#8337131)
Ish. In the context of the GP's point, they aren't a problem because the syntax to access them is distinct.
It's all method calls. Attributes don't really exist.