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

How do I make an unbounded interval? #185

Open
fonsp opened this issue Jan 10, 2022 · 1 comment
Open

How do I make an unbounded interval? #185

fonsp opened this issue Jan 10, 2022 · 1 comment

Comments

@fonsp
Copy link

fonsp commented Jan 10, 2022

From the docs, I can't tell how to construct an unbounded interval, except for constructing the object manually (which took me a long time to figure out):

julia> one_to_three = 1 .. 3 # nice!
Interval{Int64, Closed, Closed}(1, 3)

julia> one_and_up = Interval{Float64,Closed,Unbounded}(1,nothing)
Interval{Float64, Closed, Unbounded}(1.0, nothing)

julia> 7  one_and_up
true

Is there an easier way?

@hyrodium
Copy link

Just 1..nothing?

julia> 1..nothing
Interval{Int64, Closed, Unbounded}(1, nothing)

julia> 1.0..nothing
Interval{Float64, Closed, Unbounded}(1.0, nothing)

julia> Interval{Float64,Closed,Unbounded}(1,nothing)
Interval{Float64, Closed, Unbounded}(1.0, nothing)

I'm not sure the following behavior of nothing..nothing is not unexpected, btw.

julia> nothing..nothing
Interval{Nothing, Unbounded, Unbounded}(nothing, nothing)

julia> 3 in nothing..nothing
true

julia> 3+im in nothing..nothing
true

julia> "foo" in nothing..nothing
true

julia> Any in nothing..nothing
true

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

2 participants