R
Ross Bamford
Hi,
I have a couple more questions. Hopefully they're not so dumb this time.
1) I need a hash that maintains insertion order. In Java, I'd use
LinkedHashMap. Does Ruby have one?
2) I like documentation. So far, Rdoc is great, but I wonder about the
following case:
class SomeClass
attr_accessor :someattr
# But I need to validate, for example, so ...
def someattr=(i)
@someattr unless i < 10
end
end
In the above case, Ruby warns about the method being redefined (and the
original being discarded). However, if I change it to attr_reader to avoid
that (i.e. manually make the reader) then RDoc lists the attribute as
read-only, with the writer shown as a normal method. This is perfectly
reasonable, but I feel there's probably a way around it.
Thanks in advance,
Ross
I have a couple more questions. Hopefully they're not so dumb this time.
1) I need a hash that maintains insertion order. In Java, I'd use
LinkedHashMap. Does Ruby have one?
2) I like documentation. So far, Rdoc is great, but I wonder about the
following case:
class SomeClass
attr_accessor :someattr
# But I need to validate, for example, so ...
def someattr=(i)
@someattr unless i < 10
end
end
In the above case, Ruby warns about the method being redefined (and the
original being discarded). However, if I change it to attr_reader to avoid
that (i.e. manually make the reader) then RDoc lists the attribute as
read-only, with the writer shown as a normal method. This is perfectly
reasonable, but I feel there's probably a way around it.
Thanks in advance,
Ross