Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.javascript Subject: Re: Lazy programmers guide to blizz Date: Tue, 5 Nov 2019 11:14:19 +0100 Lines: 46 Message-ID: References: <96195235-1db3-458b-a25f-d38a48a84291@googlegroups.com> <9cc18ff7-4972-454e-b5c7-a722887bf1db@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net /rx3xs71/2nYIoYS3YpOYATJ8uKcH3tV11Gqm31Ep/jcmbeBZB Cancel-Lock: sha1:vc9vkNbdkqGYgIR/WftQ19vZRTE= In-Reply-To: <9cc18ff7-4972-454e-b5c7-a722887bf1db@googlegroups.com> Content-Language: en-US Xref: csiph.com comp.lang.javascript:37693 On 01.11.19 21:19, Jonas Thörnvall wrote: > Den fredag 1 november 2019 kl. 18:44:26 UTC+1 skrev luserdroog: [...] >> For a more OO style, how about >> >> class Interval { constructor( lower, upper ){ this.lower = lower; >> this.upper = upper; return this; } inside( x ){ return this.lower >> <= x && x < this.upper; } outside( x ){ return ! this.inside( x ); >> } } >> >> if( Interval(145, 159).inside(A) ) if( Interval(145, >> 159).outside(A) ) > > You people really fuck up things beyond semantical an interval can > not be inside a number.... It may be outside but you really love to Then just name it "contains": if( Interval(145, 159).contains(A) ) ... Or create a class which represents the number to be checked: if (new NumberExtended(A).inside(145,159)) ... Yes, this looks even more cumbersome - but this is how object oriented stuff works. > add complexity to problems that is simple. An interval is always a > range there is no between in it so interval 1 to 3 always hold 1 and > 2 and 3. Or only values which are more than 1 and less then 3 - 1.1, 1.0001, 2.95, 2.999991 etc.. > But why do feel the urge to change things so they do not make sense > the interval can never be inside A..... > > It is utterly stupid... No, it's the way how objects work. First the object, then the method. -- Arno Welzel https://arnowelzel.de