Re: Use of AssertionError



Patricia Shanahan wrote:
Eric Sosman wrote:
Daniel Pitts wrote:
[...]
You'll get a compiler error if you use assert false; Left up as an exercise for the reader.

Okay, I've exercised until I got cramps in my thinking
muscle, but I got no compiler errors. Could you elucidate?


If you simply replaced the throw with an assertion, with no other
changes, there would be a fall-through path to the end of the method,
not permitted in a method that returns a result.

That's why there's an exception toss after the 'assert' in the example I provided.

--
Lew
.



Relevant Pages

  • Re: Use of AssertionError
    ... You'll get a compiler error if you use assert false; Left up as an exercise for the reader. ... muscle, but I got no compiler errors. ...
    (comp.lang.java.programmer)
  • Re: #define Question
    ... >macro is a bad idea, it's probably a pretty good exercise. ... compiler error messages..... ... CLC FAQ CLC readme: ...
    (comp.lang.c)