In the cinema

Report a typo

You decided to binge-watch some films this weekend, but you are very specific about the kind of films: it should contain the word "love" in its title. You wrote the following code to make a list of such films:

fun findCertainMovies(films: List<String>) = films.filter { it.contains("love") }

fun main() {
    val films = listOf("love and doves", "love and other drugs", "terminator", "p.s. i love you")


    var filmIterator = findCertainMovies(films).iterator()
    filmIterator.next()

    while (filmIterator.hasNext()) {
        print("${filmIterator.next()} ")
    }
}

What will be the output?

Select one option from the list
___

Create a free account to access the full topic