There was a long discussion about similar request here.
My own opinion is that it is a bad idea (event ignoring the fact that it is not possible in kotlin due to syntax ambiguity). Currently all control constructs in kotlin like if
, while
and for
are almost equivalent of global functions and it is a good thing since its limits the number of language constructs. I would event go further and propose to replace for(a: collection){}
with for(collection){a->}
to make it completely like function, but this is not necessary.
2 Likes