https://kotlinlang.org logo
Title
m

Matthias R

11/25/2019, 5:07 PM
Hey I am actually a beginner in Kotlin. So my question is: when I have for example an abstract val status of type status which in the end is just an integer how can I use the val status as Integer(for example to compare to an other integer value) ..?
m

Milan Hruban

11/25/2019, 6:13 PM
what do you mean by status? can you give a full package name of the class?
m

Matthias R

11/25/2019, 6:21 PM
abstract class HttpResponse : HttpMessage, CoroutineScope, Closeable
and then as property you have and then as property you have
abstract val status: HttpStatusCode
in the end val status is just an integer...
m

Milan Hruban

11/25/2019, 6:30 PM
I assume you are talking about https://github.com/ktorio/ktor/blob/master/ktor-http/common/src/io/ktor/http/HttpStatusCode.kt then you can use
status.value
to get the value
but if you want to check for exact status, its better to do something like
status == HttpStatusCode.NotFound
or the most useful
status.isSuccess()
m

Matthias R

11/25/2019, 6:33 PM
Ah I see, it has another property value. Thanks a lot.🙂
👌 1