From: Robert Klemme Date: 2013-07-25T20:28:25+09:00 Subject: Re: Ruby newbie question on Methods (NoMethoderror) --001a11c2d960f762a004e254524f Content-Type: text/plain; charset=ISO-8859-1 On Thu, Jul 25, 2013 at 12:39 PM, wrote: > Am 25.07.2013 12:22, schrieb Crispian A.: > > > selectGame = games(gets.chomp) > > you probably mean: selectGame = games[gets.chomp.to_i] > Since we're dealing with user input here method Integer is safer for int conversion: select_game = games[Integer(gets)] (#chomp is not needed) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ --001a11c2d960f762a004e254524f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Thu, Jul 25, 2013 at 12:39 PM, <sto.mar@web.de> wro= te:
Am 25.07.2013 12= :22, schrieb Crispian A.:
=A0
> =A0 =A0 selectGame =3D games(gets.chomp)

you probably mean: selectGame =3D games[gets.chomp.to_i]

Since we're dealing with user input here method Integ= er is safer for int conversion:

select_game =3D ga= mes[Integer(gets)]

(#chomp is not needed)

K= ind regards

robert

-- remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
--001a11c2d960f762a004e254524f--