Ruby 1.91 on Debian 7.3 running on Pentium 3
trying to write menu like so:
def foo; end
def bar; end
mHash={‘f’=>[‘foo’,foo], ‘b’=>{‘bar’,bar]}
def menu(mH)
mH.each_key { |k| puts k + ’ ’ + mH[k][0] }
puts 'choice? '
ch=gets.chomp
if mH.has_key?( ch )
mH[ch][1]
end
end
Not really knowing what I’m doing yet I’ve tried various sigils both in the hash definition and the execution call with no joy. Is 1.9.1 too old to have this functionality or have I just not found it yet?
I did find a posting by Jim Weirich of reference.rb but it didn’t fly here.
I’m really just looking for info since I’ve already rewritten menu using a case/when/then but it’s really clunky.
Thanks.
PS: ‘Stay at home’ is a good time to explore another language isn’t it?