Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do something better with ranges and lengths #4

Open
xunker opened this issue Dec 13, 2013 · 1 comment
Open

Do something better with ranges and lengths #4

xunker opened this issue Dec 13, 2013 · 1 comment

Comments

@xunker
Copy link
Owner

xunker commented Dec 13, 2013

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?

@a0960909060
Copy link

helpers/build-app-list.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants