Johnathan Smith wrote:
> hi and thanks for your help its much appreciated
>
> i would really prefer if i got this working inside the class however.
> are you able to assist?
>
> thanks
class Foo
def initialize
@authors = Hash.new {|h,k| h[k] = []}
end
def add(field, value)
if @authors.has_key?(field)
@authors[field] << value
else
@authors[field] = value
end
end
def [](field)
@authors[field]
end
end
Perhaps something like that?
I just quickly typed that up whilst trying to work and talk to my boss,
so my apologies if it doesn't work or there are spelling mistakes
Regards,
Lee
--
Posted via
http://www.ruby-forum.com/.