class UnitCircle
def prompt
puts "Enter a number: "
@number = gets
@number = @number.to_i
puts "Enter a trigonometric equation to perform on that number: "
@eqn = gets
end
end
uc = UnitCircle.new
uc.prompt
num = Math.send(uc.instance_eval {@eqn}, uc.instance_eval {@number})
When I try to run it with say,
@number = 30
@eqn = sin
I get a no method error, why?
getsmethod will include the new line symbol “\n”. So you have tochompit.If you do not chomp, you will end up calling method “sin\n” instead of “sin”