Scala require() equivalent in Kotlin

Viewed 403

In Scala we have a require method that is used to set preconditions to classes like this

class Rational(x: Int, y: Int) {
   require(y != 0, "denominator must be different than zero ")

My question is: Do we have something like that in Kotlin?

2 Answers
Related