gets will return a string and therefore option will be a string. "if option
== 2" is expecting option to be an integer

A simple fix would be

option = gets.to_i



On 4 March 2013 18:58, Kat VS <lists / ruby-forum.com> wrote:

> mainMenu = "Main Menu:
>
>     Phone Book Application
>     1.) Print Phone Book
>     2.) Add Entry
>     9.) Quit Application
>
>     Please select an option:"
>
> print mainMenu
>
> option = gets
>
> ( if option == 1
>     print "TODO: Print Phone Book"
>     print mainMenu
>     option = gets
>
>      elsif option == 2
>     print "TODO: Add Entry"
>     print mainMenu
>     option = gets
>
>      elsif option == 9
>     print "TODO: Quit Entry, type 'quit' to exit."
>       quit.get
>         ( if quit == "quit"
>           abort("Goodbye.")
>         else
>           mainMenu
>           option = gets
>         end )
>
>      else
>     print "Error, please enter 1, 2, or 9."
>     print mainMenu
>     option = gets
>
>      end )
>
>
>
>
> Every time I run this it just outputs "Error, please enter 1, 2 or 9."
> No matter what number I enter. What am I doing wrong?? Thanks!
>
> --
> Posted via http://www.ruby-forum.com/.
>
>