Ruby: what is the pitfall in this simple code excerpt that tests variable existence
- by zipizap
I'm starting with Ruby, and while making some test samples, I've stumbled against an error in the code that I don't understand why it happens.
The code pretends to tests if a variable finn is defined?() and if it is defined, then it increments it. If it isn't defined, then it will define it with value 0 (zero).
As the code threw an error, I…