Skip to content

Suggestion of smell: options changing the return type #6

Closed
@josevalim

Description

@josevalim

Options should not drastically change the return type of a function. For example, you should not have an option that changes the return type. Fictional API:

Integer.parse("13")
=> {13, ""}

Integer.parse("13", discard_rest: true)
=> 13

Because options are optional and sometimes set dynamically, if they change the return type it may be hard to understand what the function actually returns. It is best to introduce a separate function, like Integer.parse_no_rest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    suggestion of smellElixir-specific smells suggested by the community

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions