array-subindex icon indicating copy to clipboard operation
array-subindex copied to clipboard

Do something better with ranges and lengths

Open xunker opened this issue 12 years ago • 1 comments

Array indexes can be ranges, or can be integers passed with a length.

Right now the gem handles these in the same way that the base Array class does:

[1,2,3][0..1]
# => [1,2]

[1,2,3][1,2]
# => [2,3]

That's all well and good, but they should do something... better. But what?

Ruby (2.0.0 at least) supports Ranges with Float boundaries. I'd like to see this:

[1,2,3,4][0.5..2.5]
# => [1.5, 2.5, 3.5]

%w[foo bar baz qux][0.5..2.5]
# => ["oob", "arb", "azq"]

That's easy. That's approach would also work verbatin with a length argument with the array index. But what about irregular ranges like [0.5..10.9]? What would the stepping be?

xunker avatar Dec 13 '13 04:12 xunker

helpers/build-app-list.js

a0960909060 avatar Jun 11 '21 11:06 a0960909060