From: "Crispian A." Date: 2013-07-25T22:43:51+09:00 Subject: Re: Ruby newbie question on Methods (NoMethoderror) "Jesús Gabriel y Galán" wrote in post #1116649: > On Thu, Jul 25, 2013 at 12:22 PM, Crispian A. > wrote: >> >> puts "#{games}" >> >> puts "Select between 0 and 2 to select your game of choice" >> selectGame = games(gets.chomp) > > You are using brackets, and that is a method call. You need square > brackets > > games[gets.chomp] > > but also, arrays are indexed by integers, so you would need to convert > the user's input: > > games[gets.to_i] # to_i removes non number characters like \n already > and will default to 0 if it can read a number from the string > > >> puts " You chose #{selectGame(gets.chomp)}" >> >> elsif userAnswer == "N" >> puts "Do you not like games?(Y/N)" >> userAnswer = gets.chomp >> >> else puts "You did not choose an option!" >> >> end > > > Hope this helps, > > Jesus. Hi Jesus Thanks for the help it worked straight away. Didn't see where I went wrong. I was using parentheses instead of the brace to access the array. So in turn when entering an array index number on the selectGame = games[gets.chomp.to_i] it returns the string value of the indexed number entered by the user And where I have # puts "You chose #{selectGame.gets.chomp}" it already has stored the user input so I don't need the gets.chomp method there. Thanks for the help. -- Posted via http://www.ruby-forum.com/.