2.x Introduction to Objects (multiple)
diedummydie opened this issue · 3 comments
I'm condensing multiple notes for the Introduction to Objects section here. None of these are critical issues.
2.3 Properties, Exercise 1
Task Description
getLocation() should return the coordinates as a string (x, y).
Description appears to want ($x, $y)
, but unit tests only pass with ($x,$y)
(space vs no space)
2.8 Exceptions
// Exceptions/IntroducingNull.kt, Accompanying text:
But what does it mean that the denominator is zero? Maybe you know how to deal with a zero denominator
// Exceptions/AverageIncome.kt, Accompanying text:
Unfortunately, this doesn't tell us anything about why this error occurred, what the denominator means and whether it can legally be zero in the first place.
Phrasing on both suggests that the word 'denominator' has already been seen in an error message, but that is not the case.
2.11 Sets, Exercise 1
To further emphasize DRY, percentOther
can also use getPercentage()
by passing groceryCart - meats - fruits - vegetables
as the first parameter.
2.12 Maps
Exercise 2
Task Description:
It should choose a hamster by a given name, return it and remove it from the list of hamsters.
Solution code doesn't remove the named hamster. It could include the line hamsters -= hamster
right before return hamster
.
Exercise 3
Same logic, put() puts a hamster in the cage, and take() takes one out, so instead of this:
fun takeHamsterByName(name: String): Hamster =
hamsters.getValue(name)
We could have this:
fun takeHamsterByName(name: String): Hamster {
val hamster = hamsters.getValue(name)
hamsters.remove(name)
return hamster
}
Exercise 4, Knowing Your IDE
Just FYI, IntelliJ Column Selection doesn't work with the IdeaVim plugin, but it does work with regular vim commands for the same feature. This is probably too niche to warrant a mention in the book/course, but I thought I'd mention it here anyway.
2.14 Summary 2
In the second paragraph after the Summary2/ListOfStrings.kt
source, there are two instances of a missing backslash inside an inline code tag:
The
character is used in String literals to precede a special character, like for a newline character (\n), or a tab (\t). Because of that, you can't simply use
in a String literal...
2.14 Summary 2
Exercise 1
Hint 1 and Hint 2 in the course contain the same text.
Resolved