Agreed. I've always viewed SO as being just slightly better than w3schools. Worse than useless. It has benefited my career significantly that I never got in the habit of using it.
For many domains, it was perfect - how do I adjust the margins in LaTeX or how do I reverse the output of ls.
But for programming, you'd get a similar "it works" answer ... eventually. And even if you read the comments under the answer, you still might get burned by side effects/security issues you'd not thought through.