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 a comparison method that will compare Nullibles by value. #22

Open
benjaminlgur opened this issue Mar 6, 2024 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@benjaminlgur
Copy link

For example

func NullIsEqual[T comparable](a gonull.Nullable[T], b gonull.Nullable[T]) bool {
	// If both are not present, they are considered equal
	if !a.Present && !b.Present {
		return true
	}
	// If both are present and values are equal, they are considered equal
	return a.Present && b.Present && a.Val == b.Val
}

func NewNull[T comparable](value T) gonull.Nullable[T] {
	return gonull.Nullable[T](gonull.NewNullable(value))
}
@LukaGiorgadze LukaGiorgadze added the bug Something isn't working label Mar 7, 2024
@LukaGiorgadze
Copy link
Owner

Hey @benjaminlgur
Thank you for opening an interesting issue.

Could you write a real-world use case? What's the benefit of having NullIsEqual func if we add it? What problem it solves?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants