Добрый день
Читая “The swift programming language” наткнулся на не понятный момент, в разделе “Booleans” (Логические типы), есть пример:
Пример
let i = 1
if i == 1 {
// this example will compile successfully
}
В книге пишется, что результат сравнения i == 1 имеет тип Bool, я на вожу курсор на i пишет что i имеет тип Int. Как это понять?
Цитата из книги
The result of the i == 1 comparison is of type Bool, and so this second example passes the type-check. Comparisons like i == 1 are discussed in Basic Operators.
As with other examples of type safety in Swift, this approach avoids accidental errors and ensures that the intention of a particular section of code is always clear.
Буду очень признателен если, кто сможет объяснить.