Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

0xFF0000FF An integer literal does not conform to the expected type kotlin.Int

Tags:

kotlin

Why doesn't this work:

var color: Int = 0xFF0000FF 

and why do I have to call toInt()

var color: Int = 0xFF0000FF.toInt() 
like image 972
Diemex Avatar asked Oct 08 '15 19:10

Diemex


People also ask

What is float error in Kotlin?

Error: Kotlin: The floating-point literal does not conform to the expected type Float - Stack Overflow I was making a simple maths calculator in kotlin, an error appeared on my screen when I tried to initialize the value of one of the variables used as 0.00 for float integer.

Can Kotlin write numbers as literals?

Kotlin Literals 2 So in the previous post we have seen that Kotlin only supports positive integer literals, which means that half the numbers it supports can't be written as a literal in code. Let's look at other ways to write number literals, maybe as hexadecimal.

Does declaring byte in Kotlin does compile-time errors?

14 Declaring Byte in Kotlin does compile-time error 'The integer literal does not conform to the expected type Byte' 264 How does the reified keyword in Kotlin work?

Does “//” work in Kotlin?

// does NOT work. You’ll get a "The integer literal does not conform // to the expected type Float/Double" error if you don’t append the f or .0. // is fine. Kotlin uses the expected symbols for most operators — + for addition, — for subtraction, * for multiplication, / for division, % for mod — so I won’t go over those.


1 Answers

This is a bug in the compiler, feel free to vote / watch it: https://youtrack.jetbrains.com/issue/KT-2780

like image 159
Alexander Udalov Avatar answered Sep 21 '22 00:09

Alexander Udalov