hopr icon indicating copy to clipboard operation
hopr copied to clipboard

Little mistake 9.4 Lookup Tables

Open luifrancgom opened this issue 4 years ago • 1 comments

In section 9.4 Lookup Tables in "As in Case 1, you could write an if tree that handles each combination of cherries, but just like in Case 1, this would be an inefficient solution" there is a problem in:

if (cherries == 2) {
  prize <- 5
} else if (cherries == 1) {
  prize <- 2
} else {}
  prize <- 0
}

I think the correct code is:

if (cherries == 2) {
    prize <- 5
} else if (cherries == 1) {
    prize <- 2
} else {
    prize <- 0
}

luifrancgom avatar Mar 30 '20 21:03 luifrancgom

Yup. That explains why the last } is red!

arencambre avatar Apr 20 '20 19:04 arencambre