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

Compare 'nothing' using === not == #2931

Merged
merged 1 commit into from
Oct 18, 2023

Conversation

fingolfin
Copy link
Member

... for optimal code results. While in most cases it won't matter, it is
a good habit to just always adhere to this.

... for optimal code results. While in most cases it won't matter, it is
a good habit to just always adhere to this.
@@ -161,7 +161,7 @@ function flats_impl(M::Matroid, r::Union{Int,Nothing}, num_flats::Int, pm_flats)
jl_flats = reverse(jl_flats)
end
matroid_flats = [[M.groundset[i] for i in flat] for flat in jl_flats]
if r!=nothing
if r != nothing
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something is missing here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed sigh. I'll send a follow up PR.

@@ -341,9 +340,10 @@ function (G::MatrixGroup)(x::MatrixGroupElem; check::Bool=true)
else
_is_true, x_gap = lies_in(x.elm,G,nothing)
@req _is_true "Element not in the group"
if x_gap==nothing return MatrixGroupElem(G,x.elm)
else return MatrixGroupElem(G,x.elm,x_gap)
if x_gap == nothing
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

@lkastner
Copy link
Member

lkastner commented Oct 17, 2023

... for optimal code results. While in most cases it won't matter, it is a good habit to just always adhere to this.

Why not use isnothing? Sure, it does the same thing as ===, but wouldn't this be the better style, to use the dedicated function?

@thofma
Copy link
Collaborator

thofma commented Oct 18, 2023

Copy link
Member

@HereAround HereAround left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @fingolfin . Looks good to me.

@HereAround HereAround merged commit dbf0e5a into oscar-system:master Oct 18, 2023
9 of 12 checks passed
@thofma
Copy link
Collaborator

thofma commented Oct 18, 2023

There were a few cases missing, which should have been fixed before merging this

@lkastner
Copy link
Member

lkastner commented Oct 18, 2023

I still don't understand why not to use isnothing. The singleton comparison statement did not enlighten me (I know that Nothing is a singleton), I am sorry.

@fingolfin fingolfin deleted the mh/nothing branch October 18, 2023 12:04
@fingolfin
Copy link
Member Author

I wanted to minimize the changes, that was very easy with a reggex changing ==nothing to ===nothing, would have been much harder to change it to isnothing. That said, I also don't see anything "better" about using isnothing, seems like a purely subjective matter of taste.

@lkastner
Copy link
Member

isnothing is the dedicated Julia function for figuring out if something is Nothing. So if at some point comparing to Nothing should be done in a different way than === this would automatically be changed for us if we used isnothing. Similar to how we are encouraged not to directly access members. But I guess this issue is really irrelevant, so I will stop here.

@HereAround
Copy link
Member

(My apologies for moving this along too quickly.)

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

Successfully merging this pull request may close these issues.

None yet

4 participants