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 getOrElseBoolean #92

Merged

Conversation

artemkorsakov
Copy link
Contributor

@artemkorsakov artemkorsakov commented Nov 18, 2023

What type of PR is this?

  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

Description:

If we look at the following code:

  def getOrElseBoolean(config: Map[String, String], key: String, defaultValue: Boolean): Boolean = {
    if (config.contains(key)) {
      config(key).toBoolean
    } else {
      defaultValue
    }
  }

, we can see that the result is true only if the given key exists and its value is true.

This can be expressed using code:

config.get(key).exists(_.toBoolean)

How do you solve it?

Special notes for your reviewer, ex. impact of this fix, design document, etc:

Copy link
Contributor

@Nicole00 Nicole00 left a comment

Choose a reason for hiding this comment

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

LGTM

@Nicole00 Nicole00 merged commit 7ee3050 into vesoft-inc:master Jan 15, 2024
1 check passed
@artemkorsakov artemkorsakov deleted the AlgoConfig-getOrElseBoolean branch January 15, 2024 16:21
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.

None yet

3 participants