+ 3

Почему код не работает?

Код: fun main(args: Array<String>) { var name = readLine() if (name = Artem) { println("You are the best!") } else { println("You are not Artem :(") } } Выводит ошибку, что делать? https://code.sololearn.com/cKPjrLNCFOKx/?ref=app

15th Mar 2023, 6:17 AM
Artem Riabchikov
Artem Riabchikov - avatar
2 Réponses
+ 4
if (name = Artem) 2 mistakes: - use == to compare for equality - put the string value inside quotes Correct code: if (name == "Artem")
15th Mar 2023, 6:27 AM
Tibor Santa
Tibor Santa - avatar
+ 3
Tibor Santa yup, now it's working. Thanks a lot!
15th Mar 2023, 6:34 AM
Artem Riabchikov
Artem Riabchikov - avatar