Of course, that would be possible.
I can think of a few reasons you don't want this:
- What is the scope of your variable? Not clear if you don't tell the compiler. Will
animals
in two methods become a private variable or two method scoped variables? - What if the name is a typo? You will never know.
- What if you already assigned a value to this variable and then try to assign a new value which is incompatible with the last (i.e javascript style) (credits to Mario Stoilov)