By combining the type check and cast into one operation, pattern matching makes the code easier to maintain. This reduces the likelihood of errors during casting and makes it easier to refactor or extend code as business logic evolves.
Additional Notes
How does pattern matching enhance maintainability?