11

In this question about a syntactic impossibility in Java, I had to write a chunk of code that purposely contained a syntax error. After submitting the question, I was reasonably surprised because the code renderer on Stack Overflow actually showed me the syntax error, as seen in this snapshot (in case it doesn't work for you):

enter image description here

Am I being tricked by an optical illusion or is this a new feature?

1 Answer 1

17

The syntax highlighter didn't pick up that you wanted Java highlighting. Instead, it seems to be interpreted as HTML (probably because it begins with a <). HTML attributes are set to be colored red, which is why you are seeing the "Java Error". Just use the following and it should work:

<!-- language: lang-java -->

    <B super A> B reduceLeft(BiFunction<? super B, ? super A, ? extends B> mapper)

Which produces:

<B super A> B reduceLeft(BiFunction<? super B, ? super A, ? extends B> mapper)

That way, you are explicitly stating that the code should be highlighted as Java.

2
  • 13
    Why did you have to ruin this awesome coincidence?
    – Clashsoft
    Commented Jul 14, 2015 at 23:59
  • Oh well. It is quite an odd coincidence though. :)
    – Anonymous
    Commented Jul 15, 2015 at 0:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .