From: Nuggety Nanna Date: 2012-12-05T15:27:13+09:00 Subject: String literal in condition and Invalid retry error in code. I am attempting to make a Vector Calculator, that will take either coordinates, or an already given vector. The if and elsif blocks work fine, it is the else block that I am in need of help in. I want the code to re-run from the "answer = gets.chomp.to_i" line if the answer does not equate to "given" or "coordinates", but when i run the code I am given the following errors: vector_calc.rb:48: warning: string literal in condition vector_calc.rb:51: warning: string literal in condition vector_calc.rb:50: Invalid retry vector_calc.rb: compile error (SyntaxError) The code is below. puts "Are the vectors given, or do you only know coordinates?" puts "Please answer either 'given' or 'coordinates'." begin answer = gets.chomp.downcase if answer == "coordinates" puts "What is the x-value of your first coordinate?" x1 = gets.chomp.to_i puts "What is the y-value of your first coordinate?" y1 = gets.chomp.to_i puts "What is the x-value of your second coordinate?" x2 = gets.chomp.to_i puts "What is the y-value of your second coordinate?" y2 = gets.chomp.to_i coord_1 = [x1, y1] coord_2 = [x2, y2] puts "Point A = (#{x1}, #{y1})" puts "Point B = (#{x2}, #{y2})" elsif answer == "given" puts "What is vector A's x-value?" vect_Ax = gets.chomp.to_i puts "what is vector A's y-value?" vect_Ay = gets.chomp.to_i vect_A = [vect_Ax, vect_Ay] puts "What is vector B's x-value?" vect_Bx = gets.chomp.to_i puts "what is vector B's y-value?" vect_By = gets.chomp.to_i vect_B = [vect_Bx, vect_By] puts "Vector A = [#{vect_Ax}, #{vect_Ay}]" puts "Vector B = [#{vect_Bx}, #{vect_By}]" else if answer != "given" || "coordinates" then puts "Please answer either 'given' or 'coordinates'." end until answer == "coordinates" || "given" retry end end end P.S I am creating this code as part of an outcome to a research project, and am asking your permission to use your answer to this question as evidence to my folio. -- Posted via http://www.ruby-forum.com/.