Clueless Clueless - 2 months ago 15
Ruby Question

Used require, stdin not being highlighted or working

What I've been trying to do is a simple noob project just by trying to take in
minor keys. Don't know if this is a ruby version or aptana weirdness because "STDIN.getch" and "raise" are not highlighted as if they are important or work at all. The code runs but nothing happens. the else does not fire either.

require 'io/console'

def yesno
case STDIN.getch
when "Y" then true
when "N" then false
else raise "Invalid character."
end
end

Answer

You're defining a method yesno but never invoking it.

Just write

yesno

after the final end

Comments