I'm writing a IntRange with the end excluded. I wa...
# announcements
o
I'm writing a IntRange with the end excluded. I was thinking if there is a way to declare a class (range in my specific case) as:
val range = IntRange[2, 5)
That express as maths, interval with closed at 2, opened at 5.
s
2 until 5
o
Yes, it's useful in this case. But I'm asking if it would be possible express things like IntRange(0, 100]
s
what do you mean “would it be possible” are you proposing a language change? that syntax isn’t currently valid Kotlin and seems like a hassle to implement just for this one case
s
I dont think there is a stdlib function for (0,100]. Its easy to define it yourself though if you can find a fitting name 🙂
👍 1
Maybe
followingTo
,
followingUntil
would be proper names for the two cases with open start