doIf syntax

Can anyone tell me what’s wrong with this syntax please?

It says "Type mistmatch. Required chainbuilder. Found B"
Not sure how should i return from the doIf block. Here for example purpose i have put “true” instead of actual boolean condition.

This is the example in Gatling documentation.

doIf(session => session(“myKey”).as[String].startsWith(“admin”)) { // executed if the exec(http(“if true”).get("…"))

Your code is correct.

Either you’ve messed up with the imports and don’t have

import io.gatling.core.Predef._
import io.gatling.http.Predef._

or you have an old IntelliJ version where the Scala plugin is buggy and the error you have is a false negative.

Gatling version: 3.5.1
IDE: intellij

Ah! Messed up with the imports. Corrected, works fine now. Thanks Stephane for such quick response.