N
Neville Burnell
Hi,
I have a class inheriting from Hash which has some specific methods
operating on the hash elements:
Class MyHash < Hash
def foo
...
end
End
....
Now, with Hash class, its really easy to create a new hash, eg
h =3D {:key1 =3D> "val1", :key2 =3D> "val2"}
What I would like to do is create a new instance of the class with the
same simplicity, but I'd like to avoid creating a redundant Hash and
tranferring the contents one by one to MyHash which happens if I code:
h =3D MyHash.newkey1 =3D> "val1", :key2 =3D> "val2")
and then define initialize(h=3D{})
Whats the "ruby way" tm for something like this?
Thanks
Nev
=20
I have a class inheriting from Hash which has some specific methods
operating on the hash elements:
Class MyHash < Hash
def foo
...
end
End
....
Now, with Hash class, its really easy to create a new hash, eg
h =3D {:key1 =3D> "val1", :key2 =3D> "val2"}
What I would like to do is create a new instance of the class with the
same simplicity, but I'd like to avoid creating a redundant Hash and
tranferring the contents one by one to MyHash which happens if I code:
h =3D MyHash.newkey1 =3D> "val1", :key2 =3D> "val2")
and then define initialize(h=3D{})
Whats the "ruby way" tm for something like this?
Thanks
Nev
=20