It expands to:
myStrings.foreach(println(x => x.toString))
You want:
myStrings.foreach(x => println(x.toString))
The placeholder syntax for anonymous functions replaces the smallest possible containing expression with a function.
More Related Contents:
- Underscore in Named Arguments
- What are the rules to govern underscore to define anonymous function?
- error in if return in Scala
- How do I get around type erasure on Scala? Or, why can’t I get the type parameter of my collections?
- Call by name vs call by value in Scala, clarification needed
- What does the `#` operator mean in Scala?
- Automatically and Elegantly flatten DataFrame in Spark SQL
- Spark extracting values from a Row
- Scala: Merge map
- Finding type parameters via reflection in Scala 2.10?
- Defining a UDF that accepts an Array of objects in a Spark DataFrame?
- Spark / Scala: forward fill with last observation
- Setting up sbt to use Java 7 for compilation?
- val-mutable versus var-immutable in Scala
- How to use Column.isin with list?
- Usage of _ in scala lambda functions
- @karate How to pass parameter to a feature file in gatling simulation class?
- Is there a generic way to memoize in Scala?
- How to pattern match into an uppercase variable?
- What good are right-associative methods in Scala?
- Getting the index of the current loop in Play! 2 Scala template
- How to get keys and values from MapType column in SparkSQL DataFrame
- Addition of two RDD[mllib.linalg.Vector]’s
- How can I convert immutable.Map to mutable.Map in Scala?
- Install sbt on ubuntu [closed]
- Should I use the final modifier when declaring case classes?
- Scala equivalent of Java’s Number
- Is there a simple example of how to generate verilog from Chisel3 module?
- Difference between two rows in Spark dataframe
- Run a scala code jar appear NoSuchMethodError:scala.Predef$.refArrayOps