I came very close to writing almost this exact code just the other day (except it was username or user id for me), but came to my senses. It's just so tempting in a dynamic language...
In a static language, you either can't do it, have to really go out of your way to do it, or at least do function overloading (which is a bit cleaner)