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
Perhaps you could make the valid types list all uppercase then you can do the following:
You could use
map
to convert the case for all items in the list e.g.Or you could use any (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/any.html)
If you want to keep the casing of your original list you could do: