Operators in Kotlin

 Kotlin, like many programming languages, uses operators to perform various operations on values. Here's a breakdown of the common operator categories in Kotlin:

1. Arithmetic Operators:

  • +: Addition
  • -: Subtraction
  • *: Multiplication
  • /: Division
  • %: Remainder (modulo)

2. Assignment Operators:

  • =: Assignment
  • +=: Addition assignment (e.g., x += 5 is equivalent to x = x + 5)
  • -=: Subtraction assignment
  • *=: Multiplication assignment
  • /=: Division assignment
  • %=: Remainder assignment

3. Comparison Operators:

  • ==: Equal to
  • !=: Not equal to
  • >: Greater than
  • <: Less than
  • >=: Greater than or equal to
  • <=: Less than or equal to

4. Logical Operators:

  • &&: Logical AND
  • ||: Logical OR
  • !: Logical NOT

5. Unary Operators:

  • +: Unary plus
  • -: Unary minus
  • ++: Increment
  • --: Decrement
  • !: Logical NOT

6. Equality Operators:

  • ==: Structural equality (checks if values are equal)
  • ===: Referential equality (checks if references point to the same object)
  • !=: structural inequality
  • !==: referential inequality

Key Kotlin Features Regarding Operators:

  • Operator Overloading: Kotlin allows you to overload operators, meaning you can define how operators work for your custom classes. This provides a way to make your code more expressive.
  • "==" vs. "===": It's important to distinguish between == and ===. == checks for structural equality (the values are the same), while === checks for referential equality (they are the same object in memory).

To get the most accurate and in depth information, I recommend checking the official kotlin documentation.

  • Kotlin documentation: kotlinlang.org

Comments

🎮 POPÜLER ⭐ 4.5

Ultra Blocks

Klasik Bulmaca · Strateji · Zeka Oyunu

Hızlı düşün, akıllıca istifle ve küresel liderlik tablosunda zirveye oyna! Ultra Blocks, klasik arcade bulmaca mantığını modern strateji ve göz alıcı görsel efektlerle birleştiriyor. Blokları sürükleyip yerleştir, tam satırları temizle ve rekorlarını kır!

🏆 Küresel Sıralama PlayFab ile dünyaya meydan oku
🎨 Özelleştirilebilir Tema Neon’dan klasik ahşaba
📱 Her Cihazda Telefon, tablet, TV ve katlanabilir
👑 VIP Kulüp Reklamsız · Sınırsız döndürme
⬇️ Google Play'den Ücretsiz İndir
📦 50 MB · Çevrimdışı oynanabilir 🔒 Veriler şifrelenir

Popular posts from this blog

Kotlin Hello World

Kotlin Android Program (QCR) Application Codes That Read Text in Photos

Kotlin Google Sign in Activity with Layout Example