I am within a method and want a simple solution to check client's response.
l=lambda { |answer|
if answer == 1
x*5
elsif answer == 2
x*10
elsif
puts "Please enter 1 or 2"
answer = gets.chomp
l.call(answer)
end
}
Obviously this code doesn't work, since lambda can't "see" itself, but is there a way to achieve the desired effect in a simple-fashioned way?
Because right now I'm just writing a new method to call and passing bunch of parameters, which I wouldn't need to if I were able to check the answers within the current method.