(1..100).map({ it + 10 })
Doesn't seem so bad.
(1..100).map({ it + 10 })
Doesn't seem so bad.
var map = {"a": 6, "b": 12}
[Whatever list type is most common/idiomatic in Kotlin] literals like: var list = [1, 2, 3]
etc.Plus list/map comprehensions like Python or Haskell, as you mentioned.
Not a big deal or anything. It's only a little bit of extra typing. And the syntax sugar they do add is definitely a massive step-up over Java.
I know it'd be hard to add the map literal syntax since it would clash with Java's normal array literal syntax. And I also realize that Java has a wide variety of container types for a reason, and Kotlin wants to be a subset of and not replacement for Java, so doing this may not make a lot of sense.
I guess on reflection, my complaints aren't really valid given that context. I've just had it ingrained in me to use special characters for basic container types, since Python and JavaScript were my first languages for many years.
var map = hashMapOf("a" to 6, "b" to 12)
var list = listOf(1, 2, 3)
This is still not Java-level verbosity.To me it would feel like assigning a variable with:
a equals 6
n equals "A"
Just feels icky, somehow.Again, that wouldn't dissuade me from using the language whatsoever. It's only a minor irritation.
(1..100).map { it + 10 }
Its also used for chaining stream code which takes in functions. You get used to this feature very quickly.