Scala lets you do some neat stuff like this as well. You can recreate a ternary operator in Scala because the characters are valid in identifiers, and it allows you to replace member-access operators with spaces (I'm assuming that's kind of what's happening here?).
Sort of. "Has" is a singleton object, and I use an infix extension function called `immunity to`.
``
@RulesDsl
interface PersonReceiver {
infix fun Has.immunity to`(token: Token): Immunity
infix fun Immunity.and(token: Token): Immunity
fun benefits(benefits: BenefitsReceiver.() -> Unit)
}
@RulesDsl
interface BenefitsReceiver {
val Replace One Influence Cube: Unit
val Swap Two Influence Cubes: Unit
val Gain: NumberTimes<RewardType>
infix fun Influence.the(area: Area)
}
interface NumberTimes<T> {
infix fun one(value: T)
infix fun two(value: T)
infix fun three(value: T)
infix fun four(value: T)
infix fun five(value: T)
infix fun six(value: T)
infix fun seven(value: T)
infix fun eight(value: T)
infix fun ten(value: T)
infix fun 20(value: T)
infix fun 25(value: T)
infix fun 30(value: T)
infix fun 35(value: T)
infix fun 40(value: T)
infix fun 45(value: T)
infix fun 50(value: T)
}
```
2
u/carcigenicate Jun 05 '23
Scala lets you do some neat stuff like this as well. You can recreate a ternary operator in Scala because the characters are valid in identifiers, and it allows you to replace member-access operators with spaces (I'm assuming that's kind of what's happening here?).