A
A
Arkady Vinogradov2021-02-18 20:49:43
Kotlin
Arkady Vinogradov, 2021-02-18 20:49:43

Why is it impossible to get byte and short in Kotlin when adding variables with the same types?

602ea824ec218654256328.png

Why, when adding 2 variables of type Byte and Shor, we get a variable of type Int
If it explicitly indicates what type the variable should be, then it gives an error

602ea8ab0b442272396547.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Makaron3000, 2021-02-18
@usov-dmitriy

there is simply no + operation on bytes, since bytes are first converted to integers, and the result of adding two integers is a (32-bit) integer, i.e. int

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question