The following code is for a calculator made in ruby, I find that this way saves much time than having to build this calculator from scratch, especially that I want it to support BEMDAS operations. However, I'm feeling that it is inefficient because I'm using eval, and I think this could be dangerous. Is it a good idea to use this in a real life application?
include Math puts "enter an expression:" input = gets.chomp begin result = eval(input) if (result.is_a? Numeric) puts result else puts "syntax error" end rescue Exception end