Skip to content

Adds Enum::equals() #39

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

Merged
merged 1 commit into from
Oct 4, 2016
Merged

Conversation

jeremykendall
Copy link
Contributor

Adds equals method to ease comparison between instances. Addresses #4.

Adds equals method to ease comparison between instances.
@mnapoli
Copy link
Member

mnapoli commented Oct 3, 2016

Thanks, any reason not to use $enum == MyEnum::FOO() ?

@jeremykendall
Copy link
Contributor Author

You're welcome!

Because I prefer to have an OO comparison method and because == tells my
brain there's a bug in the code while I'm scanning. I know there's not,
academically, but I always have to stop and ask myself if comparing enum
values 0 with '' will cause problems (for example). Having an equals method
eliminates the cognitive friction.

On Monday, October 3, 2016, Matthieu Napoli [email protected]
wrote:

Thanks, any reason not to use $enum == MyEnum::FOO() ?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#39 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AARnZbmvHea1FyXsPx1bbTSUgIizYUzbks5qwL8HgaJpZM4KMEq6
.

Sent from Gmail Mobile

@mnapoli
Copy link
Member

mnapoli commented Oct 4, 2016

Well it's funny I've never been really keen of adding that because having 2 ways of doing the same thing is a source of confusion, but just this morning I had to write yet another comparison of enums and out of habit I felt weird using ==.

So I guess yay for OCDs and good habits! :)

@mnapoli mnapoli merged commit 527b4be into myclabs:master Oct 4, 2016
@jeremykendall
Copy link
Contributor Author

So I guess yay for OCDs and good habits! :)

Indeed. Thanks!

@jeremykendall jeremykendall deleted the feature/equals branch October 4, 2016 12:16
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.

2 participants