Ever wondered what map() actually does? 🤔
Let’s break it down in the simplest way possible 👇
🧠 What is map()?
map() is used to transform a list into another list.
👉 It takes each item
👉 Applies some logic
👉 Returns a new list
🟣 Kotlin Example
val numbers = listOf(1, 2, 3)
val doubled = numbers.map {
it * 2
}
println(doubled) // [2, 4, 6]
🟣 Dart Example
var numbers = [1, 2, 3];
var doubled = numbers.map((n) => n * 2).toList();
print(doubled); // [2, 4, 6]

