From: "Crispian A." Date: 2013-07-25T22:51:15+09:00 Subject: Re: Ruby newbie question on Methods (NoMethoderror) unknown wrote in post #1116651: > Am 25.07.2013 12:22, schrieb Crispian A.: >> C:/Users/Gemini/Documents/Aptana Studio 3 >> Workspace/rubyProject/rubyTest.rb:51:in `
': undefined method >> `games' for main:Object (NoMethodError) > > this should be a rather good hint... > >> games = ["Pacman", "Mario Brothers", "Bomberman"] >> puts "#{games}" >> >> puts "Select between 0 and 2 to select your game of choice" >> selectGame = games(gets.chomp) > > this is probably line 51... > > you probably mean: selectGame = games[gets.chomp.to_i] > >> puts " You chose #{selectGame(gets.chomp)}" > > that doesn't make sense, rather: #{selectGame} > >> >> elsif userAnswer == "N" >> puts "Do you not like games?(Y/N)" >> userAnswer = gets.chomp >> >> else puts "You did not choose an option!" >> >> end > > Also, in the Ruby community snake_case is used for variable names. > > Regards, > Marcus Hi Robert Thanks for the tip on snake_casing. Reason for my variable naming is I learnt it in a book I am reading on basic programming principles where the naming convention camel Casing was mentioned so I took it to practice but maybe should change it to the way the Ruby community does it. Thanks much Crispian -- Posted via http://www.ruby-forum.com/.