List Contains in Kotlin
Level 277 keystrokes
Checks whether a list contains given elements, using the in operator and contains().
Kotlin code
// A list of the numbers 1 to 51val nums = listOf(1, 2, 3, 4, 5)// x in list checks membership; 3 is in the list, so this prints true2println(3 in nums)// in is shorthand for contains(); 6 is not in the list, so this prints false3println(nums.contains(6))Output
true false
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Kotlin code and how often they appear.
,× 4(× 4)× 4.× 1=× 1