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

Range.range?/1 is deprecated #231

Open
mmccall10 opened this issue Jan 2, 2019 · 3 comments
Open

Range.range?/1 is deprecated #231

mmccall10 opened this issue Jan 2, 2019 · 3 comments

Comments

@mmccall10
Copy link

In 03_numbers.ex there is a koan for checking for range

koan "Is this a range?" do
    assert Range.range?(1..10) == ___
    assert Range.range?(0) == ___
  end

Range.range?/1 is deprecated.

This is a kind of a hard to replace because of the learning path. Behind the scenes a Range is a struct. But pattern matching and structs don't get "taught" until later in the koan journey.

Could replace the equality check with:

assert Range.new(1, 10) == ___  # 1..10
assert Range.new(0, 0) == ___ # 0..0

But I'm not sure if this really helps learn "check if it's a range". It might make more sense to remove this specific koan from 03_numbers.ex and move a modified version to pattern matching or structs.

I think moving it to structs or pattern matching could makes more sense.

koan "A Range is also a struct" do
    %Range{first: first, last: last} = 1..10
    assert first == ___  # 1
    assert last == __ # 10
end

A few other ideas to check for a range:
match?(%Range{}, 1..10)
Range{} = Range.new(1, 10)
%Range{} = 1..10

Or that specific koan could be removed, which I don't see as harmful to the learning path.

@iamvery
Copy link
Collaborator

iamvery commented Jan 4, 2019

Thanks for the report! It's probably high time that some of the maintainers give a run through the Koans to think about the journey again. It's hard to intuit these types of reports without fresh experience with the flow itself. I suspect your intuition is spot on.

@mmccall10
Copy link
Author

@iamvery no problem. Let me know if you need any help.

@foucist
Copy link
Contributor

foucist commented Aug 19, 2020

I ended up fixing the deprecation warning in #253 by adding a couple of helper functions in order to keep the existing koan. I guess it hints at the Range struct without potentially getting in the way of the learning path?

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

No branches or pull requests

3 participants