Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Re: Inclusive or exclusive array Date: Tue, 30 Jul 2019 20:41:28 +0200 Organization: Decebal Computing Lines: 34 Message-ID: <87v9vjmkkn.fsf@munus.decebal.nl> References: <87zhkvmqx8.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="836bcd58d7669a6d0685c847623fc8c3"; logging-data="17301"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JPeM3T+IBYFj5WbGfyOpMDQb8k4FZXx8=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cancel-Lock: sha1:CKWDeTZ/1dAdVeKSM9flsTT4tRg= sha1:C6lSzSoQb01WmoDvICGQunxlFHw= Xref: csiph.com comp.lang.java.programmer:39032 Eric Sosman writes: > On 7/30/2019 12:24 PM, Cecil Westerhof wrote: >> I am writing the following method: >> Long[] getFibonacciArray(int from, int to); >> >> What is more logical: an inclusive or an exclusive array? >> >> Should: >> getFibonacciArray(12, 12) >> >> return 'Long[1] { 144 }', or 'Long[0] { }'? > > There are precedents for both, the latter being noticeably > more common. There is also precedent for > > Long[12] {144, 233, 377, 610, 987, 1597, > 2584, 4181, 6765, 10946, 17711, 28657} > > ... with a likely change of parameter name. > > Citations: > > java.lang.String::substring(int, int) > java.util.stream.IntStream::rangeClosed(int, int) > java.lang.String::new(char[], int, int) I was later also thinking about the third, but for the moment I go for exclusive. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof