If you've declared a bash function, and then decided you don't really want it, either because you went ahead and implemented it as a script somewhere, or you gave it a bad name or something, you undeclare it like this:
$ unset -f myfunc
$ unset -f myfunc
for (i = 0; i < lim; i++) { if (someCondition(n[i])) { warn("you can't do that"); continue; } switch (n[i].type()) { default: nn = 0; warn("we're ignoring this"); break; } orig->doSomethingWith(nn); delete nn; }
switch
with only a default
branch? Pretty cool, huh? Almost is nice is the delete
that only ever sees a NULL
. Then when I realized doSomethingWith()
is a no-op if it gets a NULL
, I felt even luckier.switch
, isn't it worth a couple minutes to clean this up and show what is really happening? After all, the code really does this:for (i = 0; i < lim; i++) { if (someCondition(n[i])) { warn("you can't do that"); } else { warn("we're ignoring this"); } }It probably makes sense to only give the second warning, since who cares if you can't do it, when really it would only be ignored anyway. And at that point you might wonder why you need to give the same warning
lim
times.