Incompatable conditional operand types



Hi,

I'm in the midst of refactoring a "Peak" class, where I noticed a lot
of duplication depending on whether I was in the front half of the back
half of the peak. I got it nicely boiled down into two private nested
classes, Before and After, which extend Half, which implements IHalf.
Each of these, IHalf, Half, Before, and After, is private to the Peak
class. I'll probably be getting rid of the interface before too long,
but I mention it for the sake of telling the full story.

The Peak has
private final Before before
and
private final After after,
which are initialized in the constructor


Now there's a point in the Peak logic where I want to call some methods
of one half or the other, depending. When I do this:

if (heightBefore() > heightAfter())
return meanA(after);
else
return meanA(before);

it works fine, but I thought I would go ahead and inline the meanA
stuff and assign a local variable to be after or before, depending.
Like this:

Half half = heightBefore() > heightAfter() ? after : before;

And it doesn't like this line. It tells me, "incompatible conditional
operand types After and Before". The following two lines compile
without complaint:

Half half = heightBefore() > heightAfter() ? after : after;
Half half = heightBefore() > heightAfter() ? before: before;

(in separate compile events, of course), so I know that the instance
variables are, as I thought, of subtypes of Half.

The only previous message I found in the archives about this topic is a
year old and mentions Eclipse, so I guess it's worth pointing out that
that is my development environment, too. Is this an Eclipse problem, a
Java problem, or a Carl problem?

Thanks for any help.

Peace,
--Carl

.



Relevant Pages

  • Re: Selling the Ampeg. What will I get now?
    ... have and I've found that, depending on the type of music, peak to average ... ratios of 10 to 20 dB are quite common. ...
    (alt.guitar.bass)
  • Re: Selling the Ampeg. What will I get now?
    ... have and I've found that, depending on the type of music, peak to average ... ratios of 10 to 20 dB are quite common. ...
    (alt.guitar.bass)
  • Re: Selling the Ampeg. What will I get now?
    ... I have and I've found that, depending on the type of music, ... peak to average ratios of 10 to 20 dB are quite common. ...
    (alt.guitar.bass)
  • Re: 0844 numbers for Free
    ... 0844 non geographical numbers are not local rate numbers,(Local Rate ... Depending on the number prefix ... At peak times if you did not have a inclusive call package and you ...
    (uk.telecom)
  • Re: Memory Frage
    ... Ein normales 32-Bit-Anwendungsprogramm hat diesen Schalter also nicht gesetzt, so dass die Lauffähigkeit unter Win x64 nicht gefährdet sein sollte. ... Private Bytes: 136K ... Peak PrivateBytes: 228K ... Im Vergleich zu vorher hat sich nur das private WS um 4K erhöht, das wäre eine Seite, was wohl am fehlenden Align liegen wird. ...
    (microsoft.public.de.vc)