Kotlin Infix approach to build DSL


Example

If you have:

infix fun <T> T?.shouldBe(expected: T?) = assertEquals(expected, this)

you can write the following DSL-like code in your tests:

@Test
fun test() {
  100.plusOne() shouldBe 101
}