Day 1: 'Infix modifier is required on "filter" in "kotlin.collections"'


I am just getting started with Kotlin and following the walkthroughs. One of them is this example:

fun main(args : Array<String>) {
    args filter {true} forEach {print ("Hello, $it!")}

very pretty, but IntelliJ gives me red squigglies on the filter and forEach symbols and complains that infix modifiers are required on “kotlin.collections.” I googled around and tried a bunch of hacks, but don’t see a way to fix this.


Interspersing dots, fixes it, of course

args.filter {true}.forEach {print ("Hello, $it!")

but I still wonder whether and how the infix syntax from the walkthroughs is available


May be those walkthroughs are outdated? Those methods don’t have infix modifier, you can’t call them in infix position.


thanks. looks like this is the case. I’m ok with dots.