Two small points of feedback
ricky.clarkson at gmail.com
Fri Jan 4 07:05:53 PST 2013
Sorry to repeat myself but when this came up a while back I suggested
something like rangeFrom(1).toInclusive(10) and
rangeFrom(1).toExclusive(10), or slightly less verbosely fromTo(1, 10) and
On Fri, Jan 4, 2013 at 11:59 AM, Stephen Colebourne <scolebourne at joda.org>wrote:
> On 4 January 2013 14:49, Brian Goetz <brian.goetz at oracle.com> wrote:
> >> 1) "What does this code do"
> >> range(1, 10).forEach( (i) -> System.out.println(i) );
> > Why would this be different from:
> > for(int i=0; i<10; i++)
> > println(i);
> > Or from the numerous methods that take half-open (start, end) pairs, like
> > String.substring?
> I get this point. And I think the experienced Java developers did too
> (we've all been bitten by off-by-one errors).
> But I think if you look at the code in isolation, with no previous
> knowledge of lambdas, you see "1", "10", "foreach" and assume 1 to 10
> inclusive. (A good thing to test further in a poll or user focus
> My theory is that its because the numbers are discrete. "From Monday
> to Wednesday" is closed in normal language, whereas "from 09:00 to
> 17:00" is not. Similarly "the TV channels 1 to 4" is closed, but "from
> 1.3 to 8.6" is more likely to be half-open.
> My second theory is that its because the example uses "1", rather than
> "0". range(0, 10) may have elicited different answers.
> Of course in "for(int i=0; i<10; i++)", its pretty clear that it is
> less than 10.
More information about the lambda-dev