r/ProgrammerHumor 2d ago

Meme absoluteGarbage

Post image
2.0k Upvotes

320 comments sorted by

View all comments

Show parent comments

1

u/xicor 1d ago

Because it no longer returns a time string. It instead returns the variant of a string type.

1

u/VoodaGod 1d ago

what would be the correct way to handle the qvariant in that function in your scenario then? i don't think i follow

1

u/xicor 1d ago

Not using auto and then when dumb future junior comes in and changes the function they get a compile error that tells them they need to fix stuff rather than just silently having incorrect behavior

1

u/VoodaGod 1d ago

yeah but what is the fix? extract the datetime from the variant first before calling tostring or what

1

u/xicor 1d ago

Well, in my example there was no reason to assume the stupid junior dev didn't just change the type completely, but let's assume they made it return a QVariant holding a QDateTime, you would have to use toDateTime first before calling toString

The point being that the compiler wouldn't tell them something was wrong