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

Refactor RedBlackTree sample to use an enum instead of symbols #10233

Merged
merged 1 commit into from
Jan 13, 2021

Conversation

Sija
Copy link
Contributor

@Sija Sija commented Jan 10, 2021

No description provided.

Comment on lines 20 to 26
def black?
color == BLACK
color.black?
end

def red?
color == RED
color.red?
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be made more succinct

Suggested change
def black?
color == BLACK
color.black?
end
def red?
color == RED
color.red?
end
delegate black?, red?, to: color

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True but I wanted to leave it for a more symmetrical comparison with the original.

@asterite asterite added this to the 1.0.0 milestone Jan 13, 2021
@asterite asterite merged commit c4b14fb into crystal-lang:master Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants