Forum: Ruby on Rails Where is the send() function?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Vlad Berditchevskiy (Guest)
on 2006-02-01 19:33
(Received via mailing list)
Hi,

in the tutorial "4 Days on Rails" the following code fragment is used:

,----
|   <% for column in Category.content_columns %>
|     <td><%=h category.send(column.name) %></td>
|   <% end %>
`----

Apparently, the send() function returns the column value by name, but
where does this function comes from? Unfortunately, neither the tutorial
nor the API documentation tell it.

--
\  /                                       removed_email_address@domain.invalid
 \/lad                                     http://www.hashbang.de
Gael P. (Guest)
on 2006-02-01 19:39
(Received via mailing list)
Eric H. (Guest)
on 2006-02-01 20:25
(Received via mailing list)
On Feb 1, 2006, at 9:37 AM, Gael P. wrote:

>>
>> Apparently, the send() function returns the column value by name, but
>> where does this function comes from? Unfortunately, neither the
>> tutorial
>> nor the API documentation tell it.
>
> http://www.ruby-doc.org/docs/ProgrammingRuby/html/
> ref_c_object.html#Object.send

No need to search the web:

$ ri send
------------------------------------------------------------ Object#send
      obj.send(symbol [, args...])        => obj
      obj.__send__(symbol [, args...])    => obj
------------------------------------------------------------------------
      Invokes the method identified by _symbol_, passing it any
arguments
      specified. You can use +__send__+ if the name +send+ clashes with
      an existing method in _obj_.

         class Klass
           def hello(*args)
             "Hello " + args.join(' ')
           end
         end
         k = Klass.new
         k.send :hello, "gentle", "readers"   #=> "Hello gentle readers"

--
Eric H. - removed_email_address@domain.invalid - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Bob S. (Guest)
on 2006-02-02 05:37
(Received via mailing list)
send and __send__ are methods on the Object class in Ruby.

"Invokes the method identified by symbol, passing it any arguments and
block."


Bob S.
http://www.railtie.net/
Jim (Guest)
on 2006-02-02 05:57
Vlad Berditchevskiy wrote:
> Hi,
>
> in the tutorial "4 Days on Rails" the following code fragment is used:
>
> ,----
> |   <% for column in Category.content_columns %>
> |     <td><%=h category.send(column.name) %></td>
> |   <% end %>
> `----
>
> Apparently, the send() function returns the column value by name, but
> where does this function comes from? Unfortunately, neither the tutorial
> nor the API documentation tell it.
>
> --
> \  /                                       removed_email_address@domain.invalid
>  \/lad                                     http://www.hashbang.de

Consider this:

-1.send("abs")
This topic is locked and can not be replied to.