Skip to content

Update Enums.md: Fix wrong description#2911

Merged
jakebailey merged 1 commit intomicrosoft:v2from
green961:patch-1
Jul 31, 2023
Merged

Update Enums.md: Fix wrong description#2911
jakebailey merged 1 commit intomicrosoft:v2from
green961:patch-1

Conversation

@green961
Copy link
Copy Markdown
Contributor

@green961 green961 commented Jul 30, 2023

in this section
Union enums and enum member types

enum E {
  Foo,
  Bar,
}

function f(x: E) {
  if (x !== E.Foo || x !== E.Bar) {

In that example, we first checked whether x was not E.Foo. If that check succeeds, then our || will short-circuit, and the body of the ‘if’ will run. However, if the check didn’t succeed, then x can only be E.Bar, so it doesn’t make sense to see whether it’s equal to E.Bar.

when the first check didn’t succeed, then x is E.Foo, so it doesn’t make sense to see x !== E.Bar

Copy link
Copy Markdown

@0xScratch 0xScratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that's correct!!
But do provide some description and a valid 'heading' or 'commit line' for pull requests, easy for others to review

@green961 green961 changed the title Update Enums.md Update Enums.md: Fix wrong description Jul 31, 2023
@jakebailey
Copy link
Copy Markdown
Member

Presumably, #2868 was in fact wrong?

Copy link
Copy Markdown
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think I misread the other PR, as did the other author.

@jakebailey jakebailey enabled auto-merge (squash) July 31, 2023 16:30
@jakebailey jakebailey merged commit 5fbb08b into microsoft:v2 Jul 31, 2023
@green961 green961 deleted the patch-1 branch August 2, 2023 07:08
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.

3 participants