Listing 6.7 and "Using safe calls with let" mismatch?


In the 4th paragraph on page 89, it says:

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.


:+1: I was going to raise this too. Is there an updated code sample we can use?

Thanks for producing this book, enjoying it so far!