Phlip
9/25/2007 5:05:00 PM
SpringFlowers AutumnMoon wrote:
> the following syntax error for "elif" is not caught? (should be elsif)
>
> def foo(i)
> if i < 0
> return "Less than 0"
> elif i == 0
> return "it is zero"
Ruby is interpretive; it does not link all its symbols to real
entities at compile time. (Unlike certain other languages we could
mention.
elif could be a function that takes a boolean. Ruby can't know this
until it interprets the line, because you might have used eval() or
something to create that function before getting here.
In exchange for a lot more flexibility, Ruby does fewer sanity checks
at parse time.
To keep Ruby on track, and catch errors like this, all Ruby developers
should write unit tests for everything.
--
Phlip