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

allow undefined to be used alongside null for args #13

Merged
merged 2 commits into from
Sep 21, 2022

Conversation

BrianHung
Copy link
Contributor

Typically, fractional indices are stored in an array or an object / map (?); and out-of-bounds or not-found keys into those return undefined. It'd be nice to have to avoid null check or null casting for just undefined when pass in values for a and b.

E.g.

  insertCols(insertAtIndex: number, number: number = 1) {
    const orders = generateNKeysBetween(
      this.colArray[insertAtIndex - 1]?.order ?? null, // undefined ?? null not necessary
      this.colArray[insertAtIndex]?.order ?? null, // undefined ?? null not necessary
      number
    );
    ...
  }

@arv
Copy link
Contributor

arv commented Sep 21, 2022

I think this is fine.

I'm generally a bit averse to code that cop out and allows both null and undefined. I also feel like it is too easy to get an unintentional undefined.

@arv
Copy link
Contributor

arv commented Sep 21, 2022

LGTM

Thanks

@arv arv merged commit 602f027 into rocicorp:main Sep 21, 2022
@BrianHung BrianHung deleted the relax-generate-key-null-type branch September 21, 2022 07:41
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