
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 object
s:
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!
book-kotlin-coroutine-confidence version B3
Marked As Solved

sam-cooper
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.
Popular Pragmatic Bookshelf topics










Other popular topics










Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /ash
- /vscode
- /opensuse
- /centos
- /php
- /deepseek
- /html
- /scala
- /zig
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /react-native
- /textmate
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /spring
- /manjaro
- /django
- /diversity
- /nodejs
- /lua
- /slackware
- /julia
- /c
- /neovim