Both zig and go use the dot operator, but I find the ‘::’ operator much more readable.

Vec::new();

Makes it clear that were accessing a static method belonging to the Vec struct/namespace.

Vec.new()

Makes it seem like Vec is an object with a ‘new’ method.

Am I alone in thinking this?

  • lysdexic@programming.dev
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    2
    ·
    edit-2
    1 year ago

    In Java, your objects start lowercase, so if you see uppercase, its a static call.

    Not really, that’s just the way a specific coding style was specified. You’re free to refactor all your projects to follow any other coding style if you really want to, and your programs will continue to work just fine.