Extending switch for pattern matching