Kotlin - Control Flow as ExpressionsWhat is the main advantage of using if-else as an expression in Kotlin?AIt returns a value that can be assigned to a variableBIt can only be used inside functionsCIt does not allow else branchDIt cannot be nested inside other expressionsCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand if-else expression behaviorIn Kotlin, if-else can return a value, unlike in some languages where it is only a statement.Step 2: Identify the advantageThis allows assigning the result of if-else directly to a variable, making code concise.Final Answer:It returns a value that can be assigned to a variable -> Option AQuick Check:If-else expression returns value = A [OK]Quick Trick: If-else in Kotlin returns a value usable in assignments [OK]Common Mistakes:MISTAKESThinking if-else cannot return valuesAssuming else branch is optional in expressionBelieving if-else expressions can't be nested
Master "Control Flow as Expressions" in Kotlin9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Kotlin Quizzes Collections Fundamentals - Destructuring in collection iteration - Quiz 13medium Data Types - Any type as universal base - Quiz 11easy Kotlin Basics and JVM Runtime - How Kotlin compiles to JVM bytecode - Quiz 6medium Loops and Ranges - Why ranges simplify iteration - Quiz 2easy Null Safety - Elvis operator (?:) for default values - Quiz 11easy Null Safety - Non-nullable types by default - Quiz 4medium Operators and Expressions - Equality (== structural vs === referential) - Quiz 8hard Variables and Type System - Val for immutable references - Quiz 10hard Variables and Type System - String templates and interpolation - Quiz 2easy Variables and Type System - String templates and interpolation - Quiz 4medium