Yep I know. That's why i wrote "something like". Because it's not meant to be used as it is, just something like to show what the way could be. I think it's better to show people the "way" how they can learn stuff and not give them code, where they don't know what it's doing. Better to give them a "hint" & some docu so they don't ask the same thing again in an hour just with a different content (that's what's happening pretty often these days)...
Yes, but your code is not unusable as is and to the uninitiated it will appear to do what is desired. So he may just unsuspectingly copy it and run into problems a lot later. If you don't want him to come back 10 minutes later with the next question, give him a proper example and explain it in at least some detail instead. :)