The "end" statement in Ruby -


i have if, else, , else if statement, , i'm using official documentation ruby, can't figure out put end statements.

here code:

class menu   def principal_menu     user_input = gets     #on supprime le \n du retour à la ligne     user_input = user_input.chomp     if user_input == "3"       exit     else if user_input == "1"       if file.exists?("accounts.txt")     else        file::new("accounts.txt","w+")     end      else if user_input == "2"       new_account = account.new     end   end end 

the error is: accountmanager.rb:63: syntax error, unexpected end-of-input, expecting keyword_end

note: line 63 end of file.

could 1 newbie in ruby :d

thanks!

here's problem:

class menu     def principal_menu         user_input = gets         #on supprime le \n du retour à la ligne         user_input = user_input.chomp         if user_input == "3"             exit         else if user_input == "1"             if file.exists?("accounts.txt")                 # aren't doing here             else                  file::new("accounts.txt","w+")             end         else if user_input == "2"             new_account = account.new         end     end end 

in ruby, use elsif instead of else if. can stump new-to-ruby people.

this correct:

class menu     def principal_menu         user_input = gets         #on supprime le \n du retour à la ligne         user_input = user_input.chomp         if user_input == "3"             exit         elsif user_input == "1"             if file.exists?("accounts.txt")              else                  file::new("accounts.txt","w+")             end          else user_input == "2"             new_account = account.new         end     end end 

Comments