A
Adam Akhtar
Tried my best to make this title as informative as possible but its
ended up a bit cryptic.
Say I have a class Record which represents records in a database and a
particular object has these instance variables
@a = 1
@b = 2
@c = 3
Id like to be able to create a hash that has the varible names i.e.
a,b,c as keys and then their values as the hash values.
e.g. {a=>1, b=>2, c=>3}
HOWEVER i would like this to be done dynamically so that if I add or
remove variables to my class definition the conversion method will
include these without me having to hard code them in the conversion
function.
Is this possible and if so what topic would this come under in a book?
Any tips or code snippets would be greatly appreciated.
ended up a bit cryptic.
Say I have a class Record which represents records in a database and a
particular object has these instance variables
@a = 1
@b = 2
@c = 3
Id like to be able to create a hash that has the varible names i.e.
a,b,c as keys and then their values as the hash values.
e.g. {a=>1, b=>2, c=>3}
HOWEVER i would like this to be done dynamically so that if I add or
remove variables to my class definition the conversion method will
include these without me having to hard code them in the conversion
function.
Is this possible and if so what topic would this come under in a book?
Any tips or code snippets would be greatly appreciated.