Questions about handling non-scalar kwargs in pattern matcher and kwargs capture in replacements

In the second case, you can capture the kwargs inside the extra_check function (callback that does the final check to validate a match). That callback gets the match object passed as a parameter, and if it returns True, the replacement occurs. You could either save the kwarg, let the replacement happen, and post process, or you could return False from the check and manually process the match and execute the replacement either later or inside the extra_check.

1 Like