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

Fix #830 .step() .upto() .downto() and .to() arguments #3784

Merged
merged 1 commit into from Jan 4, 2017

Conversation

schovi
Copy link
Contributor

@schovi schovi commented Dec 26, 2016

Renaming of arguments for .step() function as mentioned in #830

  • For Iterator [1,2,3,4,5].each.step([by:]2)
  • For Number 2.step(to: 10, by: 2) - required named arguments

For discussion: I was thinking about rename arguments for methods like .upto() in same manner. .upto(n: 2) will be .upto(to: 2). What do you think?

@asterite
Copy link
Member

@schovi Yes, the arguments should be renamed :-)

@RX14
Copy link
Contributor

RX14 commented Dec 26, 2016

@asterite looks like we have hanging specs again.

@@ -297,7 +297,7 @@ describe "Int" do
describe "step" do
it "steps through limit" do
passed = false
1.step(1) { |x| passed = true }
1.step(by: 1) { |x| passed = true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the test that hangs travis. This should be to: 1, otherwise it iterates infinitely

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would have been caught by overflow detection, would it not?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@schovi schovi force-pushed the normalize-step-arguments branch 2 times, most recently from de9afc2 to af83503 Compare December 27, 2016 17:01
@schovi schovi changed the title Fix #830 .step() arguments Fix #830 .step() .upto() .downto() and .to() arguments Dec 27, 2016
@schovi schovi force-pushed the normalize-step-arguments branch 2 times, most recently from d2976e4 to b40773d Compare December 27, 2016 19:10
@asterite
Copy link
Member

asterite commented Jan 4, 2017

Thank you!

@asterite asterite merged commit 4c50661 into crystal-lang:master Jan 4, 2017
@bcardiff
Copy link
Member

Note that adding required named arguments in Number#step broke some samples that trivially were working without change in ruby and in crystal at the same time. Like samples/mandelbrot.cr.

I am not saying we should change something, just pointing it out for future demos. cc: @asterite.

We might need to add an new entry to https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists .

@schovi schovi deleted the normalize-step-arguments branch January 27, 2017 18:40
@schovi
Copy link
Contributor Author

schovi commented Jan 27, 2017

@bcardiff I changed samples, which failed during CI/tests. Why this doesn't fail?

@bcardiff
Copy link
Member

@schovi there is nothing wrong with the changes, it's just that sometimes we have demonstrated the mandelbrot.cr sample using crystal and ruby without changing the code. That time is over since this change. It's just a heads up for future demos.

@schovi
Copy link
Contributor Author

schovi commented Jan 27, 2017

@bcardiff Ah. Didn't get it first time :)

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

Successfully merging this pull request may close these issues.

None yet

4 participants