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.

2009/3/7 Jo Be <removed_email_address@domain.invalid>:
> http://pastie.org/409974>> When I instantiate MyHash.new I get an empty hash. Just not sure how to> proceed.
If initializing the Hash with particular values is the only reason for
a subclass, I would not choose this approach. You could rather do any
of these
1. cloning
MyHash = {:foo => "bar".freeze}.freeze
new_hash = MyHash.dup
2. method
def Hash.my
{:foo => "bar"}
end
new_hash = Hash.my
IMHO a subclass is only worthwhile if you add functionality. But even
then I'd probably rather consider delegation over inheritance.
Another alternative is to create a module with additional
functionality. It all depends on what you want to achieve.
Kind regards
robert