it'd nice to have `forEachIndexed` offering immedi...
# language-proposals
e
it'd nice to have
forEachIndexed
offering immediately
i, it
b
does it not?
m
I think Giuseppe wished this would be implicit, i.e. you could write:
Copy code
list.forEachIndexed { print("index: $i, value: $it") }
as opposed to
Copy code
list.forEachIndexed { i, it -> print("index: $i, value: $it") }
As my current favorite proposal is trailing commas, I wouldn't want this to be implemented tho, because I could not write:
Copy code
list.forEachIndexed { i, it, -> print("index: $i, value: $it") }
b
ah, like Swift does with
$0.0
and
$0.1
. I'd like to see
it1
or
it2
e
@mg6maciej exactly, what I meant was implicitness
m
For me Python's Zen is quite important and this invalidates "explicit is better than implicit" rule.
e
I don't want implicit be mandatory, but I'd like to have the choice
b
I'd like to see, maybe, a way to tell the compiler "This parameter of the lambda is the `it`", so you could at least still use
it
in
forEachIndexed
without explicit naming