Functions inside loops

Defining a function f inside a loop, using it and then redefining it to behave some other way actually does not work as I thought it would/should.
For instance, this

Hello and welcome! You didn’t actually post any code. If you are redefining functions inside a loop, you have to make sure those are anonymous functions, as named functions are defined once only.

See this related issue Same code in if and else blocks, get UndefVarError only on else condition