Dentaku::AST::Subtraction requires numeric operands, but got integer
Nghi93 opened this issue · 4 comments
Nghi93 commented
calculator = Dentaku::Calculator.new
calculator.add_function(:custom, :integer, lambda do
1
end)
calculator.solve(
a: "1",
b: "CUSTOM() - a"
)
procudes the error mentioned in the title.
Nghi93 commented
Quickfix is
calculator.add_function(:custom, :numeric, lambda do
1
end)
Nghi93 commented
Thank you for fixing this bug so fast.
Could you create a patch release, please?
Nghi93 commented
just a quick question:
There are other descendants of numerics:
Numeric.descendants
=> [ActiveSupport::Duration::Scalar, Date::Infinity, BigDecimal, Integer, Float, Rational, Complex]
Do you need to support them as well? (at least bigDecimal, Float, Rational and Complex?)
calculator = Dentaku::Calculator.new
calculator.add_function(:custom, :big_decimal, lambda do
BigDecimal.new("1.23")
end)
calculator.solve(
a: "1",
c: "CUSTOM() - a",
)