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

nucleotide-count: convert the class to a function #579

Merged

Commits on Mar 13, 2023

  1. nucleotide-count: convert the class to a function

    Before PR exercism#550 the constructor was required to validate the input, the
    member function `count(char)` had to return the count for a specific
    nucleotide, the member function `nucleotide_counts()` had to return a
    `std::map` with all four counts.
    
    But PR exercism#550 has changed that significantly. After syncing the tests with
    the canonical data there's no call to `count(char)` anymore, so each
    test looks like a two-step function call:
    
    ```
    const nucleotide_count::counter dna("G");
    const auto actual = dna.nucleotide_counts();
    ```
    
    I'd call that unnecessarily complicated and unidiomatic, there's
    no longer a good reason to require a `class`. Let's turn the class
    `counter` into a function:
    
    ```
    const auto actual = nucleotide_count::count("G");
    ```
    siebenschlaefer committed Mar 13, 2023
    Configuration menu
    Copy the full SHA
    6dc5877 View commit details
    Browse the repository at this point in the history