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

Make the range function work with integers #365

Merged
merged 3 commits into from Nov 13, 2014

Conversation

dalen
Copy link

@dalen dalen commented Nov 12, 2014

This is needed for the future parser which actually treats numbers as
numbers and strings as strings. With this patch you can use range(1,5)
instead of having to quote them like range('1','5').

Build on #364 which is just a style fix.

Erik Dalén added 2 commits November 12, 2014 15:52
This is needed for the future parser which actually treats numbers as
numbers and strings as strings. With this patch you can use range(1,5)
instead of having to quote them like range('1','5').
@daenney
Copy link

daenney commented Nov 12, 2014

👍

@igalic
Copy link
Contributor

igalic commented Nov 12, 2014

nice

@jhoblitt
Copy link

I'd suggest adding coverage of a 3 parameters call with all integers.

As the function stands now, range([1,"10"]) would return a list of integers and range(["1",10]) would return a list of strings. I think it would probably be less surprising if mixed type parameters resulted in an exception.

@dalen
Copy link
Author

dalen commented Nov 12, 2014

I'll add more tests, but actually both range(1,"10") and range("1",10) return a list of integers.

Stuff like range('a', 10) return an empty array, just like range('a', '10') also did

@jhoblitt
Copy link

hmmm. I'm not sure why that's the behavior.

2.1.0 :001 > (1.to_i .. "10".to_i).step(1).collect { |i| i }
 => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 

@dalen
Copy link
Author

dalen commented Nov 13, 2014

Not sure about which behavior?

On Wed, 12 Nov 2014 18:28 Joshua Hoblitt notifications@github.com wrote:

hmmm. I'm not sure why that's the behavior.

2.1.0 :001 > (1.to_i .. "10".to_i).step(1).collect { |i| i }
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


Reply to this email directly or view it on GitHub
#365 (comment)
.

hunner added a commit that referenced this pull request Nov 13, 2014
Make the range function work with integers
@hunner hunner merged commit b6830f1 into puppetlabs:master Nov 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants