You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe it would be a big win for readability in complex date logic if we could write something like if (date == 7 of CHESHVAN) instead of jewishMonth == JewishDate.CHESHVAN && jewishDayOfMonth == 7
(slightly more declarative vs imperative)? This is possible with kotlin infix functions. It could possibly evolve into a DSL. I am wondering where this train of thought could go.
For example, what would be the most concise way of expressing this?
fun isMashivHaruachRecited(jewishCalendar: JewishCalendar): Boolean = jewishCalendar.isBetween(
JewishDate(jewishCalendar.jewishYear, JewishDate.TISHREI, 22),
JewishDate(jewishCalendar.jewishYear, JewishDate.NISSAN, 15)
)
fun JewishCalendar.isBetween(
startDate: JewishDate,
endDate: JewishDate
) = this > startDate && this < endDate
Maybe
fun isMashivHaruachRecited(jewishCalendar: JewishCalendar): Boolean = jewishCalendar between 22 of TISHREI and 15 of NISSAN
Or
fun isMashivHaruachRecited(jewishCalendar: JewishCalendar): Boolean = jewishCalendar in 22 of TISHREI..15 of NISSAN //can use `until` instead of range operator
As well, this is a common occurence: day >= 15 && (day <= 22 || !inIsrael && day <= 23)
A range where one of the bounds depends on a variable. Maybe we can do better than an if (day in 15..(if(!inIsrael) 23 else 22))?
Maybe something like day in 15..(22.israel ?: 23)
The text was updated successfully, but these errors were encountered:
Maybe it would be a big win for readability in complex date logic if we could write something like
if (date == 7 of CHESHVAN)
instead ofjewishMonth == JewishDate.CHESHVAN && jewishDayOfMonth == 7
(slightly more declarative vs imperative)? This is possible with kotlin infix functions. It could possibly evolve into a DSL. I am wondering where this train of thought could go.
For example, what would be the most concise way of expressing this?
Maybe
Or
As well, this is a common occurence:
day >= 15 && (day <= 22 || !inIsrael && day <= 23)
A range where one of the bounds depends on a variable. Maybe we can do better than an if (
day in 15..(if(!inIsrael) 23 else 22)
)?Maybe something like
day in 15..(22.israel ?: 23)
The text was updated successfully, but these errors were encountered: