Eng book Kotlin Question Flashcards
In Java, numbers are primitives, so a variable holds the actual
number. Is that not the case with Kotlin?
در جاوا، اعداد اولیه هستند، بنابراین یک متغیر مقدار واقعی را نگه می دارد
عدد. آیا در مورد کاتلین اینطور نیست؟
No, it’s not. In Kotlin, numbers are objects, and the variable holds a
reference to the object, not the object itself.
نه اینطور نیست. در کاتلین اعداد اشیا هستند و متغیر a را نگه می دارد
ارجاع به شیء، نه خود شیء.
Why does Kotlin care so much about a variable’s type?
چرا کاتلین اینقدر به نوع متغیر اهمیت می دهد؟
Because it makes your code safer, and less prone to bugs. It might sound
picky, but trust us, it’s a good thing.
زیرا کد شما را ایمنتر میکند و کمتر مستعد اشکالات میشود. ممکن است به نظر برسد
حساس است، اما به ما اعتماد کنید، این چیز خوبی است.
In Java, you can treat char primitives as numbers. Can you do the
same for Chars in Kotlin?
در جاوا، شما می توانید char های اولیه را به عنوان اعداد در نظر بگیرید. آیا می توانید انجام دهید
همینطور برای Chars در Kotlin؟
No, Chars in Kotlin are characters, not numbers. Repeat after us, Kotlin
isn’t Java.
Can I name my variables anything I want?
: No. The rules are a little flexible, but you can’t, say, give your variable a
name that’s a reserved word. Naming your variable while, for example, is
just asking for trouble. But the great news is that if you try and give a
variable a name that’s illegal, IntelliJ IDEA will immediately highlight it as
a problem.