Scala Language While Loops

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • while (boolean_expression) { block_expression }

  • do { block_expression } while (boolean_expression)

Parameters

ParameterDetails
boolean_expressionAny expression that will evaluate to true or false.
block_expressionAny expression or set of expressions that will be evaluated if the boolean_expression evaluates to true.

Remarks

The primary difference between while and do-while loops is whether they execute the block_expression before they check to see if they should loop.

Because while and do-while loops rely on an expression to evaluate to false to terminate, they often require mutable state to be declared outside the loop and then modified inside the loop.



Got any Scala Language Question?