Hacker News new | ask | show | jobs
by vikramkr 4 days ago
The indexOf thing type checks fine and it's weird that contains and indexOf disagree - is the java spec not that they're supposed to agree for a byte array?
1 comments

To clarify, by "type mismatch", I meant checking if an int value occurs in a byte array (and, hence, in the wrapping sequence). Of course, appropriate type coercion would prevent such a mismatch.

The disagreement between `.indexOf` and `.contains` is interesting. Nice catch!!

Digging into the code, `.indexOf` invokes `ArraySeq_byte.indexOf` while `.contains` invokes `ASeq.contains`. Interestingly, `ASeq.contains` and `ASeq.indexOf` have similar behavior while `ArraySeq_byte.indexOf` and `ASeq.contains` different behavior.