• nous
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 year ago

    There are reasons you might want to, such as you are constructing something that has a few different ways to create it. Like maybe a date, can parse it from a string, pass in each bit as a separate argument, take in a Unix timestamp.

    A lot of languages encourage this with constructors as you can often only have one.

    IMO it is far better to just have different functions for each type you want to build something from like how it is done in rust.

    But when you come from a language that encourages the opposite it can seem clunky to have to define separate functions for each. And it can take a while to accept the different way of working.