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.
If it’s a statically typed language and
x
is of typeDate
, it’s for sure throw a type error when trying to assign a string to it. If it had autoboxing / auto type conversion fromString
toDate
, 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 atx.length
because that has to belen(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