[SR-13601] Boolean-valued case checking expressions #56036
Labels
compiler
The Swift compiler in itself
duplicate
Resolution: Duplicates another issue
expressions
Feature: expressions
feature
A feature request or implementation
pattern matching
Feature: pattern matching
swift evolution proposal needed
Flag → feature: A feature that warrants a Swift evolution proposal
Additional Detail from JIRA
md5: 69379195ba792a711faff79b86aa3415
is duplicated by:
Issue Description:
Allowing code patterns like (strawman syntax, we could potentially use
~=
instead of=
):would make pattern checks more ergonomic.
The alternatives today are:
Use
==
: Doesn't work if the type is not Equatable, doesn't work for ignoring bindings as in the second example.Use an immediately invoked function expression (IIFE) with a switch statement: much more verbose than the suggested syntax.
See also: https://forums.swift.org/t/proposal-sanity-check-assigning-a-case-statement-to-a-boolean/40584
The text was updated successfully, but these errors were encountered: