I don’t understand how generics work here?
Yes a little.
interface Book<Page> {
fun write(page: Page)
fun read(title: String) : Page
}
What you basically stated here:
interface Book<Foo> {
fun write(page: Foo)
fun read(title: String) : Foo
}
Page
, . Book<String>
, a Book<HttpClient>
Book<ArrayList<String>>
. , Foo
Page
, T
, "".
, , , .
, , - , . 'generic constraint', :
interface Book<T : Page> {
fun write(page: T)
fun read(title: String) : T
}