R
RichardOnRails
I've got the following hash set up and it works fine. But this took
more typing than programming.
h = {:name=>$1, :n_shares=>$2, pened_MDY=>$3, :closed_MDY=>$4,
roceeds=>$5, :cost=> $6, :gain_Loss=>$7
}
So I'd like to get the following to work:
field_names =%w<Name Shares Opened_MDY Closed_MDY Proceeds Cost
GainLoss>
h = {}
(1..field_names.size).each { |i| h[field_names] = eval($ +
i.to_s) }
But concatenating the character "$" with the value of i converted to a
string, followed be evaluating that as a local variable isn't working
as I coded it. Can it be easily corrected?
Thanks in Advance,
Richard
more typing than programming.
h = {:name=>$1, :n_shares=>$2, pened_MDY=>$3, :closed_MDY=>$4,
roceeds=>$5, :cost=> $6, :gain_Loss=>$7
}
So I'd like to get the following to work:
field_names =%w<Name Shares Opened_MDY Closed_MDY Proceeds Cost
GainLoss>
h = {}
(1..field_names.size).each { |i| h[field_names] = eval($ +
i.to_s) }
But concatenating the character "$" with the value of i converted to a
string, followed be evaluating that as a local variable isn't working
as I coded it. Can it be easily corrected?
Thanks in Advance,
Richard