On Saturday, 27 August 2022 at 13:20:13 UTC, hype_editor wrote:
I need to use function `eval` sometimes, but compiler throws an error: `Error: variable `firstOperand` cannot be read at compile time`.
```d
        override public double eval()
        {
                double firstOperand = firstExpr.eval();
                double secondOperand = secondExpr.eval();

                return mixin(
                        format("%d %s %d", firstOperand, operator, 
secondOperand)
                );
        }
```

`mixin` is not the right tool to use here. Try rewriting the code to use a `switch` statement or a series of `if`-`else` statements instead.

Reply via email to