For loop problems

dear users,
I am new at java. I learn ki from a internet PDF.
there is a program I type in my computer.
a instruction bring error:

for (y<-ys; !(allreadyExpanded contains y))
[error]: E:\scala\searchtree\DepthSearch.scala:12:59: ‘<-’ expected but ‘)’ found.
[error] for (y<-ys; !(allreadyExpanded contains y))
[error] ^

I don’t know what happens?
can anyone give me an idea?

thank you und best regards
Jürgen

                                                         ^

That is using the old syntax.

You want something like:

for {
  y <- ys
  if !(allreadyExpanded contains y)
  ...
} yield // probably you want a yield at the end?

If you are using Scala 3, you may even drop the braces like:

for
  y <- ys
  if !(allreadyExpanded contains y)
  ...
yield // probably you want a yield at the end?

Welcome to the Scala community.

It looks like you are using a very old or poor resource. Here are much better official resources for learning Scala:
https://docs.scala-lang.org/online-courses.html
https://docs.scala-lang.org/books.html

1 Like

is there a scala-lang courses or book in german?

Not from Scala-lang, no. There are three old books in German, from 2010. Not sure of their quality, but they would be very outdated by now.

The online courses on Coursera should have German subtitles for the videos.

There’s Ein Scala Tutorial für Java Programmierer | Scala Documentation

1 Like