<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 23, 2024 at 3:53 PM Remi Forax <<a href="mailto:forax@univ-mlv.fr">forax@univ-mlv.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div><br></div><div><div>   - for(var i : List.of(0, 1, 2, 3)) {<br></div><div>   - for(var i : IntStream.range(0, 4).boxed().toList()) {<br></div><div>   - for(var i : new int[] { 0, 1, 2, 3 }) { <br></div><div>   - for(var i : (Iterable<Integer>) IntStream.range(0, 4)::iterator) {  // those students have read Effective Java<br></div></div></div></div></blockquote><div><br></div><div>You've really seen students come up with all of these on their own?</div><div><br></div><div>I mean, I credit your students for exploring and trying things, but these cures are all self-evidently worse than the disease. Hopefully the students are able to see that they're better off reverting to the "dumb" extra variable in this case. Then they've learned a useful lesson.</div><div><br></div><div>To whatever extent users <i>really are</i> feeling compelled to go to such heroics to avoid this temporary variable, it says something about how viscerally "wrong" the variable feels. Clearly it's producing a "well this <i>can't be right</i>, I'd better keep looking for another way" intuition in people.<br></div><div><br></div><div>I suppose that does constitute an argument in favor of the proposal, but I don't know how it should be weighted. But it would not be reasonable to compare the proposal against the four things above, and award it points for being better than <i>those</i> things, because they are <i>already</i> not the right solutions for the problem.</div><div><br></div><div><br></div><div><br></div></div></div>