def ssn
if @ssn[9] =~ /[1, 3, 5, 7, 9]/
"#{first_name}'s social security number is #{@ssn} and based on the second-last number, #{first_name} is a Male"
elsif @ssn[9] =~ /[0, 2, 4, 6, 8]/
"#{first_name}'s social security number is #{@ssn} and based on the second-last number, #{first_name} is a Female"
else
return false
end
end
The code above should work. You simply needed the @
symbol for the ssn
inside of your method. Otherwise, it is clear that the recursive call is happening when you try to string-interpolate your ssn
. Note, that instance variables are only visible with the @
. It is not implicit. Clearly, you would run into issues similar to what you ran into.