Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > def swfupload_file=(data)

Reply
Thread Tools

def swfupload_file=(data)

 
 
Abder-Rahman Ali
Guest
Posts: n/a
 
      09-16-2010
Following this tutorial:
http://jimneath.org/2008/05/15/swfup...ruby-on-rails/

I want to ask about this method definition:

def swfupload_file=(data)

What is meant by the =(data) part?

Thanks.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Brian Candler
Guest
Posts: n/a
 
      09-16-2010
Abder-Rahman Ali wrote:
> Following this tutorial:
> http://jimneath.org/2008/05/15/swfup...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.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Abder-Rahman Ali
Guest
Posts: n/a
 
      09-16-2010
Thanks Brian for your clarification.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
method def in method vs method def in block Kyung won Cheon Ruby 0 11-21-2008 08:48 AM
Newbie: def must come before call to def? planetthoughtful Ruby 4 03-12-2007 11:36 AM
"def self.method" vs "class << self; def method" joevandyk@gmail.com Ruby 7 10-10-2006 08:46 AM
Is there a way to use "def self.new" to do the job of "def initialize"? Sean Ross Ruby 3 12-25-2003 04:59 AM
HttpModule -- how to intercept urls like http://localhost/abc/def or http://localhost/abc/def/ where abc, def are non virtual dir Jiong Feng ASP .Net 0 11-19-2003 05:29 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57