@@ -479,6 +479,31 @@ case let .qrCode(productCode):
479479 ```
480480-->
481481
482+ When you're matching just one case of an enumeration,
483+ you can use the shorter ` if case ` syntax
484+ instead of writing a full switch statement.
485+ For example:
486+
487+ ``` swift
488+ if case .qrCode (let productCode) = productBarcode {
489+ print (" QR code: \( productCode ) ." )
490+ }
491+ ```
492+
493+ In this code,
494+ the condition for the ` if ` statement starts with ` case ` ,
495+ indicating that the condition is a pattern instead of a Boolean value.
496+ If the pattern matches,
497+ the condition for the ` if ` is considered to be true;
498+ otherwise it's false.
499+ Just like in the switch statement earlier,
500+ the ` productBarcode ` variable is matched against
501+ the pattern ` .qrCode(let productCode) ` here.
502+ And like in the switch case,
503+ writing ` let ` extracts the associated value as a constant.
504+
505+ <!-- XXX mention guards, and maybe for loops -->
506+
482507## Raw Values
483508
484509The barcode example in < doc:Enumerations#Associated-Values >
@@ -520,6 +545,8 @@ Raw values can be
520545strings, characters, or any of the integer or floating-point number types.
521546Each raw value must be unique within its enumeration declaration.
522547
548+ <!-- XXX fix this note box abuse; this is important, not optional -->
549+
523550> Note: Raw values are * not* the same as associated values.
524551> Raw values are set to prepopulated values
525552> when you first define the enumeration in your code,
0 commit comments