Good morning channel! This morning while hacking i...
# intellij
o
Good morning channel! This morning while hacking in my first solution for this years Advent of Code, IntelliJ and the new K2 mode (which I had enabled just before that...) got me into some typing trouble. I hope this is a bug or something you can fix. You see, in "K1" mode, when you type the name of any standard library collection method, like
map
the order of completion suggestions looks like in the first image. The
.map { ... }
is the very first one - which is good and "correct". Hit Tab and directly type your lambda code! When K2 mode is enabled though, the list looks a lot different... 😔 (second picture) The
.map(transform: (Int)->R)
comes right before the more common and useful
.map { ... }
completion! I fell into the trap to hit Tab and see myself with this not very welcoming completion as when typing code you probably did not yet write your own mapping function, but rather need a quick lambda! But there is a second problem waiting for you. Once you select the "right" completion by hitting Down, then Tab, you see that the completion now wants you to give
it
a real name! In K1, you could simply type your lambda like
.map { it * 2 }
without bothering to already know a name! In K2 mode, though, it completes with
.map { i -> }
with
i
highlighted. I do not need, not want this at this point in time! It is just distracting my typing and coding flow. Renaming
it
is fine when done later, once you see the resulting code. Never would I want an
.map { i -> i * 2}
as my very first code. That's the whole point in Kotlin being cool with
it
! Lambdas should be short and concise and not full of boilerplate! These findings seem to be true for many or even all collection methods like
map
,
sumOf
,
count
, ..... It is such tiny details that instantly let me throw away K2 mode. 😞 Unless, that is, I am too blind and this can be configured... Can it? Thanks!