Skip to content

Range.range?/1 is deprecated #231

Open
@mmccall10

Description

@mmccall10

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions