Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[New Concept]: Range #1569
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
[New Concept]: Range #1569
Changes from 3 commits
f069b1b
f4329ae
ed0f087
f95af79
ec60828
1d07871
84ee065
d1c2ab0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if they are really special ranges, or if this is more "syntactic sugar" that lets us express the normal ranges like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we terminate them with negative infinity and positive infinity, then we can see that they do have a beginning or end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think this is true, demonstrably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking in the docs are there also mention of nil: https://rubyapi.org/3.2/o/range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. That is why I said think... and did it in an REPL, to verify. Seems like it has changed for newer versions of Ruby.
So I would then expect it to no longer be a terminated by infinity anything, and perhaps "undefined" in behavior. I will definitely look at the source code. Pretty sure the use will not change from
1..infinity
as1..nil
though. (That would be surprising, butnil
evaluates as 0 if we doto_i
and as0.0
if we donil.to_f
so definitely worth investigating.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you sent a picture too. Whatever it is, I a sure it supports your statement. Not at a good device at the moment to get interpretations for pictures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for information, I happened to have a Pry session open, where Pry has a bug that does not show this as it is supposed to. That was the reason it was broken as shown. Not the syntax itself. "Bad Pry!"