material-components/material-components-android-codelabs

MDC-101 Kotlin: isPasswordValid is javaish

CristianGM opened this issue · 1 comments

https://codelabs.developers.google.com/codelabs/mdc-101-kotlin/#4

private fun isPasswordValid(text: Editable): Boolean {
   return text != null && text.length >= 8;
}

Editable is not nullable and ";" is not required on Kotlin

should be like:

private fun isPasswordValid(text: Editable): Boolean {
   return text.length >= 8
}

or even nicer private fun isPasswordValid(text: Editable) = text.length >= 8

sorry to be pity, just trying to improve the docs

getText() is marked as @Nullable in java, so the Editable text parameter should be nullable, which would require the null check.

We've updated the codelab instructions to match the code in the repo. Anything else you recommend here? Thanks!