Eng book Kotlin Question Flashcards

1
Q

In Java, numbers are primitives, so a variable holds the actual
number. Is that not the case with Kotlin?

در جاوا، اعداد اولیه هستند، بنابراین یک متغیر مقدار واقعی را نگه می دارد
عدد. آیا در مورد کاتلین اینطور نیست؟

A

No, it’s not. In Kotlin, numbers are objects, and the variable holds a
reference to the object, not the object itself.

نه اینطور نیست. در کاتلین اعداد اشیا هستند و متغیر a را نگه می دارد
ارجاع به شیء، نه خود شیء.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why does Kotlin care so much about a variable’s type?

چرا کاتلین اینقدر به نوع متغیر اهمیت می دهد؟

A

Because it makes your code safer, and less prone to bugs. It might sound
picky, but trust us, it’s a good thing.

زیرا کد شما را ایمن‌تر می‌کند و کمتر مستعد اشکالات می‌شود. ممکن است به نظر برسد
حساس است، اما به ما اعتماد کنید، این چیز خوبی است.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In Java, you can treat char primitives as numbers. Can you do the
same for Chars in Kotlin?

در جاوا، شما می توانید char های اولیه را به عنوان اعداد در نظر بگیرید. آیا می توانید انجام دهید
همینطور برای Chars در Kotlin؟

A

No, Chars in Kotlin are characters, not numbers. Repeat after us, Kotlin
isn’t Java.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can I name my variables anything I want?

A

: 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly