foreach and a Set

Hi everyone,
I tried to use .foreach with a session attribute which was an immutable.Set.
This resulted in the below error and I understand this is because .foreach expects an expression that yields a Seq[Any] object which a Set is not.

I was wondering if it wouldn’t be a feature if .foreach operated on the Iterable trait instead?

Otherwise one needs to keep in mind which collection type is stored in a session in a particular case and additionally convert it to Seq if needed.

11765 [gatling-1-1] ERROR io.gatling.core.session.LoopBlock$ - Condition evaluation crashed with message ‘Can’t cast ‘Set(368, 370, 371)’ of type class scala.collection.immutable.Set$Set3 into interface scala.collection.immutable.Seq’, exiting loop

Regards,
Tomasz

That would be a large breaking change so I’m afraid we won’t do that any time soon.
The Scala DSL works on Seq while the Java one works on List, so both guarantee order.

Thank you for the clarification Stéphane, that makes sense of course.

Regards,
Tomasz