Skip to content

fix: Remove zerovalue[V].#445

Closed
aryehlev wants to merge 33 commits intodgraph-io:mainfrom
aryehlev:zeroGeneric
Closed

fix: Remove zerovalue[V].#445
aryehlev wants to merge 33 commits intodgraph-io:mainfrom
aryehlev:zeroGeneric

Conversation

@aryehlev
Copy link
Contributor

When i added generics in my PR i put the zerovalue to return valid values(since not all values will have nil).
a more elegant solution is just to have paramater returns in the function

Checklist

  • Code compiles correctly and linting passes locally
  • For all code changes, an entry added to the CHANGELOG.md file describing and linking to
    this PR
  • Tests added for new functionality, or regression tests for bug fixes added as applicable
  • For public APIs, new features, etc., PR on
    docs repo staged and linked here

Instructions

  • The PR title should follow the Conventional Commits
    syntax, leading with fix:, feat:, chore:, ci:, etc.
  • The description should briefly explain what the PR is about. In the case of a bugfix, describe or
    link to the bug.
  • In the checklist section, check the boxes in that are applicable, using [x] syntax.
    • If not applicable, remove the entire line. Only leave the box unchecked if you intend to come
      back and check the box later.
  • Delete the Instructions line and everything below it, to indicate you have read and are
    following these instructions. 🙂

Thank you for your contribution to Ristretto!

@aryehlev aryehlev requested a review from a team March 20, 2025 19:42
@mangalaman93
Copy link
Contributor

Thank you for the PR @aryehlev. I do agree that not having zeroValue function is useful but at the same time, I do not like using named return. It reduces the readability of the code. Is there a way we could have both?

@aryehklein-rise
Copy link

@mangalaman93 hey, the point was to get rid of zeroValue.
i don't like it, named return solves that.
but i will close PR if u don't like it.

@freeformz
Copy link
Contributor

An alternative is to do this at the top of the function and then return that value....

var value V
...
value = ....
....
return value, err

I tend to use this pattern extensively when writing generic Go code.

+1 on not using blank returns.
PS: You don't have to use blank returns with named returned values, you can still return value, err

@mangalaman93
Copy link
Contributor

An alternative is to do this at the top of the function and then return that value....

var value V
...
value = ....
....
return value, err

I tend to use this pattern extensively when writing generic Go code.

+1 on not using blank returns. PS: You don't have to use blank returns with named returned values, you can still return value, err

Doing this is same as what we have today, don't you think?

@aryehlev
Copy link
Contributor Author

@mangalaman93 closing PR.

@aryehlev aryehlev closed this Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants