elixir-koans icon indicating copy to clipboard operation
elixir-koans copied to clipboard

Range.range?/1 is deprecated

Open mmccall10 opened this issue 6 years ago • 3 comments

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.

mmccall10 avatar Jan 02 '19 19:01 mmccall10

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.

iamvery avatar Jan 04 '19 15:01 iamvery

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

mmccall10 avatar Jan 04 '19 19:01 mmccall10

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?

foucist avatar Aug 19 '20 07:08 foucist