Javaru

Javaru

Kotlin Coroutine Confidence: Book & source code do not match (pg 180)

On page 180 it says:

If you’re a fan of fluffy felines, you’ll be starting here.
pets/v1/src/main/kotlin/com/example/pets/PetService.kt
const val url = "https://api.thecatapi.com/v1/"
Or, if you’re all about those cuddly canine companions, just swap that line
for this one.
pets/v1/src/main/kotlin/com/example/pets/PetService.kt
const val url = "https://api.thedogapi.com/v1/"

However, the source code has two objects:

object Cats {
  const val url = "https://api.thecatapi.com/v1/"
}

object Dogs {
  const val url = "https://api.thedogapi.com/v1/"
}

with the URL that is used being decided by the import in the file:

import com.example.pets.Dogs.url

So you’ll likely want to update the text on pg 180 to indicate you make the change by changing the import.

p.s. Cats are OK, but Dogs Rule! :dog_face:

book-kotlin-coroutine-confidence version B3

Marked As Solved

sam-cooper

sam-cooper

Author of Kotlin Coroutine Confidence

Thanks, that’s useful feedback. As you probably guessed, using the two object declarations was a convenient way to include both URLs in the same source file without having a name clash. But I agree that it’s a little confusing, since it means the code in the downloaded source file doesn’t exactly match what I’m describing in the book. I’ll see what I can do to improve that. Adding a note in the text, as you suggested, sounds like a simple solution.

Where Next?

Popular Pragmatic Bookshelf topics Top

mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
alanq
This isn’t directly about the book contents so maybe not the right forum…but in some of the code apps (e.g. turbo/06) it sends a TURBO_ST...
New
rmurray10127
Title: Intuitive Python: docker run… denied error (page 2) Attempted to run the docker command in both CLI and Powershell PS C:\Users\r...
New
New
Chrichton
Dear Sophie. I tried to do the “Authorization” exercise and have two questions: When trying to plug in an email-service, I found the ...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New

Sub Categories: