Following this tutorial:
http://jimneath.org/2008/05/15/swfupload-paperclip-and-ruby-on-rails/
I want to ask about this method definition:
def swfupload_file=(data)
What is meant by the =(data) part?
Thanks.
Following this tutorial:
http://jimneath.org/2008/05/15/swfupload-paperclip-and-ruby-on-rails/
I want to ask about this method definition:
def swfupload_file=(data)
What is meant by the =(data) part?
Thanks.
Abder-Rahman A. wrote:
Following this tutorial:
http://jimneath.org/2008/05/15/swfupload-paperclip-and-ruby-on-rails/I want to ask about this method definition:
def swfupload_file=(data)
What is meant by the =(data) part?
The method’s name is “swfupload_file=”, and (data) is the one argument
that the method takes.
Methods with name ending ‘=’ are treated slightly specially. The syntax
foo.bar = baz
looks like an assignment, but it isn’t. It is actually calling method
“bar=” on object foo, with argument baz. In long-hand it would be
foo.send(:bar=, baz)
Also, these sorts of methods always return their argument, not the final
value evaluated or the value on a ‘return’ statement. That is,
a = foo.bar = baz
will always set a to baz, regardless of what the method bar= returns.
Thanks Brian for your clarification.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs