Having the equals ignore case option
if (bookType.equals(Type.BABY.name, true))
Is there an option to do contain similar with ignore case?
val validTypes = listOf("Kids", "Baby")
if (validTypes.contains(bookType)))
I see there is an option of doing :
if (bookType.equals(Type.BABY.name, true) || bookType.equals(Type.KIDS.name, true))
But I want more elegant way
Could use the
isoperator with awhenexpression, and directly withbookrather thanbookType:See Type checks and casts.