Not sure what I'm doing wrong


#1

I'm rather new to coding and I decided, after going through hashes, to try making a hash code with user input. I don't know what the error codes mean, and I'm not sure what the error is directing me to do.


#2

Hey there

The issue occurs because you forgot to put comma after each hash entry, so Ruby reads it as the hash ending after the first entry. If you put those in after both "Father" and "Mother", so it will read it as three entries into the hash, the code should compile fine.

Since there was no comma, Ruby expects a '}' to follow, but was met with "#{mother}" => "Mother" instead, which is what the error message is trying to explain


#3

Thank you. Now I've gotten the code to run, but once I get to imputing the sibling_number, no matter what I type in, I get the error "comparison of String with 1 failed."


#4

Ah, I didn't notice that
Since the value you would get from gets.chomp is a string, you need to convert it to an integer to compare with other numbers.
So by changing to "if sibling_number.to_i > 1", it should execute properly
You could also change it to be "sibling_number = gets.chomp.to_i" instead, so that the variable is stored as the actual value instead of being converted just when doing the comparison check. They are both valid options


#5

Thank you for the help! With a few tweaks just to be complete, here's how the code finally ended up.