DEV Community

Vrushali
Vrushali

Posted on

🔥 Kotlin vs Dart Equality — 30 sec breakdown!

🔥 Kotlin vs Dart Equality — 30 sec breakdown!

👨‍💻 Kotlin:
== → checks VALUE
=== → checks MEMORY (same object)

val a = "Hi"
val b = "Hi"

println(a == b)  // true
println(a === b) // 🤔 maybe true (string pool)
Enter fullscreen mode Exit fullscreen mode

🚀 Dart:
Only == exists → VALUE check
For memory → use identical()

String a = "Hi";
String b = "Hi";

print(a == b);           // true
print(identical(a, b));  // true/false
Enter fullscreen mode Exit fullscreen mode

💡 Quick Trick:
Kotlin → == vs ===
Dart → == + identical()

⚡ Save this before your next interview!

Kotlin #Dart #Programming #AndroidDev #FlutterDev

Top comments (0)