https://kotlinlang.org logo
#getting-started
Title
# getting-started
o

Okan Yıldırım

05/22/2022, 5:42 PM
Hey, do I need to do something like this for extending?
Copy code
class NotAuthenticatedError(
   override val message: String,
) : Error(message = message)
I mean can’t I basically use the message immediately because it is extending?
j

jbnizet

05/22/2022, 6:00 PM
Copy code
class NotAuthenticatedError(message: String) : Error(message)
c

Chris Lee

05/22/2022, 6:02 PM
If you want to expose message as an attribute (perhaps
Error
already does this:
Copy code
class NotAuthenticatedError(val message: String) : Error(message)
If you want to expose message as an internal attribute to use in the implementation of NotAuthenticatedError:
Copy code
class NotAuthenticatedError(private val message: String) : Error(message)
o

Okan Yıldırım

05/22/2022, 7:12 PM
Well, that also works. Thanks
3 Views