Читать книгу Programming Kotlin Applications - Бретт Мак-Лахлин, Brett McLaughlin - Страница 60

Truth or Fiction

Оглавление

For true or false values, you can use a Boolean. You can assign to a Boolean either true or false:

val truthful = true val notTrue = false

However, you cannot use 0 or 1 as you can in some languages. A 0 is an Int (or a Long, or even a Float):

val notBoolean = 0 val zeroInt = 0 val zeroLong = 0L val zeroFloat = 0F

A 0 is never a Boolean, though.

Programming Kotlin Applications

Подняться наверх