could work like this:

Array.range(2); // returns [0,2]

Array.range(2, 4); // returns [2,3]

Array.range(2, 6, 2); // returns [2,4], last number is the increment

Array.range(2, function(){ return 1; }); // returns [1,1]

And these are all.

--
Fábio Miranda Costa
Solucione Sistemas
Engenheiro de interfaces


On Wed, Mar 3, 2010 at 9:19 PM, hazlema <[email protected]> wrote:

> In my opinion, it would be really cool if mootools could use a range
> operator for numeric sets:
>
> new Array.Range( [0, 10] );
>
> would create an array with 11 empty elements
>
> new Array.Range( [0, 10] , function() {
>    return new Element('div');
> });
>
> would create an array with 11 elements with div in each spot
>
> Consider this code segment:
>
> Days = new Array().Range( [0, 31], function(index) {
>                    ele = new Element('div', {class: 'weekdays'});
>                    if ((index % 7 == 0) || (index % 7 == 6))
> ele.removeClass('weekdays').setClass('weekends');
>                   return ele;
>           });
> You got it, its a calendar
>
> You could use it for existing arrays as well:
>
> DaysArray.Range( [9, 11], function(index) {
>              this.Hide();
> });
>
> Just a thought I had while I was building an app, what do you think?
>

Reply via email to