Feature-Request: Add Range type data

Steve Fink sphink at gmail.com
Fri Jul 15 17:35:21 UTC 2016


On 07/14/2016 09:33 PM, Dayvson Lima wrote:
> Example:
>
> var myRange = new Range(0,4);
>
> myRange == (0..4)   #=> true

This (0..4) syntax doesn't exist, afaik. Do you mean myRange == 
[0,1,2,3,4]? Given that [1,2] != [1,2], I don't think so. I'm assuming 
you meant that as shorthand.

>
>
> new Array(myRange)  #=> [0, 1, 2, 3, 4]

I'm not sure what this gives you over

   var Range = function*(start, end) { let i = start; while (i <= end) 
yield i++; };

   var myRange = Range(0, 4);
   new Array(myRange); # [0, 1, 2, 3, 4], but it empties out myRange
   [...Range(0, 4)]; # [0, 1, 2, 3, 4]

> var charRange = new Range('a', ' d');  #=> ('a'..'d')

Ugh. This is very latin1-centric. What is 'a'..'d', again? a ä á à b ç c 
d, perhaps? (Yes, charCodeAt(0) offers a possible interpretation, but 
it's somewhat random.) And what is Range('aa', 'bb')? Range('a', 'bb')? 
Range('A', 'a')? Keep away from characters; they aren't numbers drawn 
from any useful 1-dimensional space.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160715/c30b58d7/attachment.html>


More information about the es-discuss mailing list