4 ms·
"it" is a magic value that was introduced in Groovy, so a lot of people are familiar with it. You got used to "this" being a magic value, "it" is a pretty easy
by incepted 11y ago
"it" is a magic value that was introduced in Groovy, so a lot of people are familiar with it. You got used to "this" being a magic value, "it" is a pretty easy concept to grasp.
Besides, it's not any more magical than "_" (which has, what... eleven different meanings? [1]) and it's super convenient. Still, don't like it? Just explicitly name your closure parameter. But you'll be surprised how you will quickly stop doing that for trivial closure uses because finding names is such a pain.
You're right that Java 8 has been closing the gap, though, but note that Java 9 doesn't have any new language features that will close that gap further.
[1] http://stackoverflow.com/a/8001065/162410 http://stackoverflow.com/a/8001065/162410
- lmm 11y ago> You got used to "this" being a magic value, "it" is a pretty easy concept to grasp. FWIW I avoid "this" as much as possible. I prefer a named self, which Scala has a nice concise syntax for. > Besides, it's not any more magical than "_" Like I said, "_" looks like syntax. "it" looks like an ordinary value. > which has, what... eleven different meanings? [1] Sort of, but it's always obvious from context. I have literally never been confused by an occurrence of "_" in 3+ years of full-time Scala programming.
- vorg 11y ago> ... was introduced in Groovy, so a lot of people are familiar with it You're assuming here that a lot of people have used Groovy. People generally don't even use "it" in Gradle, the most common access people have to Groovy.