in partnership with mediatemple

Ticket #822 (closed enhancement: wontfix)

Opened 3 months ago

Last modified 2 days ago

Number.between

Reported by: 131 Owned by:
Type: enhancement Priority: trivial
Milestone: Mootools version 1.2 Component: Core
Keywords: number, between Cc:

Description

I was asking myself if there is any reason for this not to be implemented, it can be very usefull

Number.implement({
	between:function(min,max){
		return this>=min && this<=max;
	}
});

Change History

Changed 3 months ago by tomocchino

  • milestone changed from Mootools version 1.2 to Mootools version 1.3

Changed 3 months ago by kenjin

Hmm I have an issue with this. The main issue being is that it is ambiguous what the function does given your proposed name. Should the between be inclusive or not? i.e. this > min && this < max versus this >= min && this <= max

I really feel this will cause people to write buggy code when an assumption like this is hidden within a function. It also pollutes the library which in its current state is very clean. For something so potentially misleading it would be useful to have some compelling examples to highlight its use.

Changed 2 days ago by tomocchino

  • status changed from new to closed
  • resolution set to wontfix
  • milestone set to Mootools version 1.2

since use of this function is ambiguous, im going to close this ticket saying we'd rather not add it to the framework. MooTools makes it very easy to extend with your own custom functionality so by all means use it in your applications.

Note: See TracTickets for help on using tickets.