Skip to main content

Posts

Showing posts with the label date range

Range check in Kotlin

Introduction In many cases, we might be interested in checking dates to see if they fit in the range or numbers to see if they fall between the given range of numbers. Kotlin has a short hand way to represent the range which can be quite handy fun checkInRange(date: MyDate, first: MyDate, last: MyDate): Boolean {     return date in first..last } The above snippet of code is used to check the date (1st argument) lies between the first and the last date ranges.