Awesome Kotlin

Programming tips

What’s differences between isNullOrBlank and isNullOrEmpty

  • isNummOrEpty: Returns true if this nullable char sequence is either null or empty (Length is zero).

  • isNullOrBlank: Returns true if this nullable char sequence is either null or empty or consists solely of whitespace characters.

Kotlin  Java  JVM 

Mock in kotlin

Argument Matching & Answers For example, you have mocked DOC with call(arg: Int): Intfunction. You want to return 1 if argument is greater than 5 and -1 if it is less or equal to 5. This can be achieved by following construct: every { mock.call(more(5)) } returns 1 every { mock.call(or(less(5), eq(5))) } returns -1 returnsMany specify a number of values that are used one by one i.e. first matched call returns first element, second — second element, e. []
Kotlin  Mock