Getting Hash to print and work with numbers

S

Sean Raw

Hello everyone. Just curious about some code that I was writing. Just
trying to learn anyones input would be very helpful. Can't figure out
how to make this work.
Here it is thank you.


Company = {
'Emp01' => {
'Name' => 'John Smith',
'Age' => '55',
'Payrate' => 5.75,
'Hours_worked' => 35,
'Marital_s' => 'S'
},
'Emp02' => {
'Name' => 'Jack Smith',
'Age' => '25',
'Payrate' => 25.76,
'Hours_worked' => 60,
'Marital_s' => 'M'
},
}
p Company['Emp01']['Age']
a = Company['Emp01']['payrate']
b = Company['Emp01']['Hours_worked']
z = a * b
p z
 
R

Robert Klemme

Hello everyone. Just curious about some code that I was writing. Just
trying to learn anyones input would be very helpful. Can't figure out
how to make this work.
Here it is thank you.


Company =A0=3D {
=A0'Emp01' =A0=3D> {
=A0 =A0'Name' =3D> 'John Smith',
=A0 =A0'Age' =A0=3D> '55',
=A0 =A0'Payrate' =3D> 5.75,
=A0 =A0'Hours_worked' =3D> 35,
=A0 =A0'Marital_s' =3D> 'S'
=A0 =A0},
=A0'Emp02' =A0=3D> {
=A0 =A0'Name' =3D> 'Jack Smith',
=A0 =A0'Age' =3D> '25',
=A0 =A0'Payrate' =3D> 25.76,
=A0 =A0'Hours_worked' =3D> 60,
=A0 =A0'Marital_s' =3D> 'M'
=A0 =A0},
=A0}
p Company['Emp01']['Age']
a =3D Company['Emp01']['payrate']
b =3D Company['Emp01']['Hours_worked']
z =3D a * b
p z

A hint: check your spelling.

robert


--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 
M

Mariam Tariq

[Note: parts of this message were removed to make it a legal post.]

Hi, you have a lowercase p in
a = Company['Emp01']['*p*ayrate']
thats why it is not working
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,142
Messages
2,570,820
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top