• onlinepersona@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    3
    ·
    3 months ago

    If it’s a statically typed language and x is of type Date, it’s for sure throw a type error when trying to assign a string to it. If it had autoboxing / auto type conversion from String to Date, length could return a number or a string.

    If this were Javascript on NodeJS, it would fail at print(x) because that doesn’t exist in JS. If it were Python it would fail at x.length because that has to be len(x). And so on.

    If this were all to pass, at the latest at runtime, when the programmer sees the output “6”, they would know something’s up.

    As I said, cute, but worthless test.

    CC BY-NC-SA 4.0