Ruby Syntax error only says "unexpected '\n', expecting => -


i desperately need understand problem code is, , usual somehow getting syntax error message nobody has ever gotten before when trying code simple while loop conditionals in it: syntax error, unexpected '\n', expecting =>

i know there question asked that, issue other code involved hashes , things not using - i'm trying here read in number , generate 1 of set of responses based on input. never in life has program , refused specify need do!

this code, :

#!/usr/bin/ruby  time=-1  while (time < 0)      print "enter total number of minutes spend per week reading/studying: ",     time => gets.to_i      if (time >= 120)     {     puts => "congratulations! pass course."     }     elsif (time > -1)     {             if (time > 60)             {             puts=>"ok...you may still pass course."             }             else             {             puts=>"i have grave concerns study habits." }end  end 

i try run , ever tells me expects "=>" somehow. , if end bit isn't "}end end" ruby freaks out , tells me have unexpected "}" expects "keyword_end" when change it, thing tells me doesn't expect keyword_end instances it literally told me put in , expects brackets it told me remove

and have entire thing wrapped in brackets while loop, thing freaks out insisting there isn't closing bracket first "if" statement is.

so fed this, been trying hours , i'm ready give because ruby's error messages unhelpful things i've ever come across!

correcting code:

print "enter total number of minutes spend per week reading/studying: " time = gets.to_i  if time >= 120   puts "congratulations! pass course." elsif time > 60   puts "ok...you may still pass course." else   puts "i have grave concerns study habits." end  

study how written , should ok.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -