Now, ClosedRange defines some contains methods, but none of them accepts another ClosedRange as a parameter, hence your error. So assuming that you can do a.b to create a ClosedRange (which is something not available by default in the Kotlin stdlib, but maybe core-ktx defines its own extension for that), according to the Kotlin documentation, x in y gets translated to y.contains(x). (other.start in this & other.endInclusive in this)ĭisclaimer: I'm not an Android developer and have no experience with re, so take my answer with a pinch of salt. (other.isEmpty() & (other.start in this || other.endInclusive in this)) || Other.isEmpty() || (other.start in this & other.endInclusive in this) Operator fun > ntains(other: ClosedRange): Boolean = Other.start in this & other.endInclusive in this operator fun > ntains(other: ClosedRange): Boolean = You can define your own extension function for ClosedRange if you want, with behavior that depends on how you want to interpret the meaning of an empty range being contained. I'm not sure what you mean by circumventing it. What would it mean for a negative-direction ClosedRange to be in another ClosedRange? It's empty, but it has a span. This makes the concept of a ClosedRange containing another more ambiguous than with Ranges. One difference between the two classes is that the Android Range class forbids a range with the start value higher than the lower, but Kotlin ClosedRange allows it. Or maybe the Kotlin developers have a higher criteria for what functions are useful enough to include in the standard library. Maybe the Kotlin developers decided the meaning of a range being in another range might be ambiguous, and the Android developers didn't. These two libraries are made by different companies and were made with different goals in mind, so you can't necessarily call it an oversight. ClosedRange is part of the Kotlin standard library.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |