Run Tavern.kt with the reassignment to null commented out, then uncommented. When beverage is not null, let is invoked, capitalization happens, and the result is printed. When beverage is null, the contents of the let function are not evaluated, and beverage remains null.
But on the previous page 88, Listing 6.7, the commented out line
// beverage = null
is BELOW the code block which includes
beverage = readLine()?.let {
line, so it seems to be not possible to prevent the execution of the let block when it is uncommented.
even if the line
beverage = null
would be above the block with
beverage = readLine()?.let {
it is not as simple as typing null or leave it blank while execution time to prevent the execution of the let block.
In the Kotlin standard library it says:
readLine(): Return the line read or null if the input stream is redirected to a file and the end of file has been reached.
Am i wrong here?