Ruby newbie. What’s wrong with this code?
city_details['longitude'] + "," + city_details['latitude']
I get this error:
./player_location.rb:6:in `+': String can't be coerced into Float (TypeError)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It looks like
city_details['longitude']andcity_details['latitude']areFloatvalues.You cannot add
Floatto aStringin Ruby like this. You can either convert everything toString, and then+them, or use String interpolation.Most Rubyists tend to use String interpolation.