Kotlin sequence function unresolved reference

Viewed 746
  • Kotlin 1.0.0
  • IDEA 2016.1

I have found a couple of references to the new sequence function used to create a sequence (no longer called stream). The JetBrains blog gives the following examples:

val elements = sequence(1, { x -> x + 1})
val elements = listOf(1, 2, 3, 4).sequence()

The AgileWombat blog gives similar examples.

val squares = sequence(1) {it + 1}.map {it * it}

However, when I try any of these examples, either in the REPL or in the IDE (IDEA 2016.1), I get the following:

>>> val squares = sequence(1) {it + 1}.map {it * it}
error: unresolved reference: sequence
val squares = sequence(1) {it + 1}.map {it * it}
              ^
error: unresolved reference: it
val squares = sequence(1) {it + 1}.map {it * it}
                           ^

I have the latest plugin for the IDE and the latest kotlin package downloaded. So I must be doing something wrong.

1 Answers
Related