kind of mixed about this. Some people learn by comparing working code to their code, and this would help them a lot, and let us focus on getting better answers out to the other people here on the forums.
But, some people will:
- Mindlessly copy/paste it. These people exert the minimum effort needed, and usually are only on here for a school class
- Mis/not understand it. These people try to understand it, but fail, because the code is too complex or they think differently than the course author, or something.
Doing this would make it easier for the mindless people. It's already not too hard to find working code for any given exercise if you're willing to spend about five minutes on here, but they could no spend ~ three seconds getting the correct code. Since these people aren't going to change, I don't think it's worth worrying about whether they can get the correct code or not.
It's the people who misunderstand the code who I think get affected if they have easy access to answers. Instead of asking a question and getting a clear and helpful answer that helps them understand the problem, move on, and avoid it next time, they might struggle to understand it, but then not ask a question for lots of reasons and copy/paste it without ever understanding how it works.
And with the answers hidden just that little extra, these people are more likely to create a question I think.