• UnderpantsWeevil@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    2 days ago

    I agree that the more verbose style is more explicit, and so more readable.

    On its face, its readable. But when you’re dealing with 10,000 lines of code in a file, it becomes this ugly morass of extra nothingness to scroll through.

    The only part that has me stumped is the unary question-mark operator: private static Singleton? _instance = null;

    It transforms a strict variable into a nullable variable. I most commonly see it with primitive types.

    So, for instance

    int myInt = null

    is an illegal assignment, but

    int? myInt = null

    works fine.

    Why does a public class instantiation need this? Idfk. That might be extraneous. But I wouldn’t throw away the whole code block rewrite over that one character.