https://kotlinlang.org logo
#android
Title
# android
a

Ayden

07/15/2018, 2:17 PM
The library accept
Boolean
but I am using
Boolean?
m

m1shk4

07/15/2018, 2:19 PM
the library doesn’t know how to handle
null
, since it expects
true
and
false
only
👍 2
r

rkeazor

07/15/2018, 2:22 PM
remove the question mark lol
a

Ayden

07/15/2018, 2:31 PM
@rkeazor lol. will it cause any error or inconsistency?
@m1shk4 thanks. just wondering if there is other alternative solution other than remove the question mark.
r

rkeazor

07/15/2018, 2:33 PM
why would there be a inconsistency. the error says its expecting a boolean, but your giving it a nullable boolean
could you paste a small code sample perhaps
small lol
a

Ayden

07/15/2018, 2:34 PM
Copy code
override fun read(`in`: JsonReader?): Response {
        `in`?.beginObject()
        while (`in`?.hasNext()) { << Here is the error
            val token: JsonToken = `in`.peek()
        }
    }
@rkeazor what is the syntax meaning of ``` for the
in
?
r

rkeazor

07/15/2018, 2:35 PM
You need a better naming convention
its because in is a kotlin key word
a

Ayden

07/15/2018, 2:35 PM
@rkeazor That one is automatic generate by the generator when I hit ALT + Insert to generate the override method.
r

rkeazor

07/15/2018, 2:35 PM
so it uses the double ticks to specify that your using it to name a vairable
doesn’t matter. just change the name from in, to something more understandble
for instance
a

Ayden

07/15/2018, 2:36 PM
So it does not represent anything but to tell the compiler this is a variable name?
r

rkeazor

07/15/2018, 2:36 PM
jsonReader: JsonReader
a

Ayden

07/15/2018, 2:37 PM
Ah! After I change it to reader.
Thanks.
Then it work well.
r

rkeazor

07/15/2018, 2:37 PM
no prob
a

Ayden

07/15/2018, 2:37 PM
Now I know why it is
in
already.
Maybe it could be a keyword.
r

rkeazor

07/15/2018, 2:37 PM
yes its a keyword
a

Ayden

07/15/2018, 2:38 PM
So the indicate as
in
to tell the compiler actually this is a variable, not a keyword.
r

rkeazor

07/15/2018, 2:38 PM
yes
its like naming a variable , when
a

Ayden

07/15/2018, 2:38 PM
Great! Thanks @rkeazor!
r

rkeazor

07/15/2018, 2:38 PM
no prob