fromString static method

MathOp fromString(
  1. String op
)

Converts a string operator representation to the corresponding enum value.

Parameters:

  • op: String representation of the operator ("+", "-", "*", "/", "%")

Returns: The corresponding MathOp enum value

Throws:

  • Exception if the operator string is not recognized

Implementation

static MathOp fromString(String op) {
  switch (op) {
    case "+":
      return MathOp.add;
    case "-":
      return MathOp.sub;
    case "*":
      return MathOp.mul;
    case "/":
      return MathOp.div;
    case "%":
      return MathOp.mod;
    default:
      throw Exception("Unknown operator: $op");
  }
}