StepRange and StepRangeLen have no common abstract class

Hello,

I would like to have a function like this (where I want to do something more interesting than printing):

x = (myrange::Range) -> print(length(range))

But I cannot find an abstract type that has both StepRange 1:2:10 and StepRangeLen 1:2.5:10.
It seems weird to me that I have to use the Union here.

And more in general, what is the idea behind StepRange, why does it differ so much from the version with Float (StepRangeLen) values?

Thanks

AbstractRange or AbstractVector?

You can use supertypes to inspect the type hierarchy.

3 Likes