Swift - Variables and ConstantsWhy does Swift require parentheses around expressions inside string interpolation?ATo make the code run fasterBTo prevent the string from being printedCTo allow interpolation only of variables, not expressionsDTo clearly separate the expression from surrounding textCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand purpose of parentheses in interpolationParentheses group the expression so Swift knows what to evaluate.Step 2: Identify why parentheses are neededThey separate the expression from the rest of the string clearly.Final Answer:To clearly separate the expression from surrounding text -> Option DQuick Check:Parentheses clarify expression boundaries in interpolation [OK]Quick Trick: Parentheses group expressions inside \( ) for clarity [OK]Common Mistakes:Thinking parentheses speed up codeBelieving only variables can be interpolatedAssuming parentheses prevent printing
Master "Variables and Constants" in Swift9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Swift Quizzes Data Types - Type conversion is always explicit - Quiz 7medium Functions - Function declaration syntax - Quiz 2easy Functions - Default parameter values - Quiz 11easy Functions - Default parameter values - Quiz 5medium Loops - While loop - Quiz 6medium Optionals - Force unwrapping with ! and its danger - Quiz 15hard Swift Basics and Runtime - Project structure and Swift Package Manager basics - Quiz 9hard Swift Basics and Runtime - How Swift compiles to native code - Quiz 11easy Variables and Constants - Explicit type annotation - Quiz 3easy Variables and Constants - Why let and var distinction matters - Quiz 12easy