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

Add GreaterThanOrEqual and LessThanOrEqual methods #196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pd93
Copy link

@pd93 pd93 commented Feb 7, 2023

Simple PR to add LessThanOrEqual and GreaterThanOrEqual methods. These are syntactically the same as the existing LessThan, GreaterThan and Equal methods in that they are just wrappers around Compare.

The main motivation for this is code readability. I have several places in my projects where I am doing something like this:

const v3 = semver.MustParse("3")
...
if version.Compare(v3) >= 0 {
    // do something
}

it would be much more readable to use these new wrappers:

const v3 = semver.MustParse("3")
...
if version.GreaterThanOrEqual(v3) {
    // do something
}

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

1 participant