Ruby's first-class functions make printf-debugging obsolete
slightlynew.blogspot.com
slightlynew.blogspot.com
Also, I vote for Ruby's new motto to be: "Just because you can, doesn't mean you should."
In particular, this Applies to Eval.
- catch exceptions where they might occur and log as much information as possible
- use tests before publishing the code
- use something like log4X so you can actually log what's happening at the level you need
- do not ever think "Assuming that /usr/share/dict/words is sufficient" - you were wrong at "Assuming"
First wrong would be that it doesn't emit a useful error message in first place. Not sure why that is the case, but e.g. python would always include the value it failed on in a DivByZero Exception.
Second wrong would be that these kind of hacks seem to be widely accepted in the ruby community. Only because you can doesn't mean you should. DRY and conciseness are worthy goals, but not at the expense of sanity please.
I bet it is usually 0.
The big innovation is including the variable name that is problematic.
Yet I still have to wonder where the desire for this functionality is even coming from. The "cure" looks by far more problematic than the disease in any case.
>>> a,b=1,0
>>> a/b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero