David Kahn wrote in post #977285:
> I want to write a method which takes its input and adds it to an array
> (in
> this case I am trying to abstract a session item as I think it looks
> prettier to use a helper method).
>
> For example, native in ruby we have arr:
>
> arr = []
> arr << 'item'
>
> Is there a way I can write a method that uses the '<<' syntactic sugar?
> Been
> poking around and don't see clearly how to do this.

def <<(other)
  # whatever
end

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

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

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to