Scala underscore - ERROR: missing parameter type for expanded function

前端 未结 1 583
醉话见心
醉话见心 2020-11-27 03:41

I know there have been quite a few questions on this, but I\'ve created a simple example that I thought should work,but still does not and I\'m not sure I understand why

相关标签:
1条回答
  • 2020-11-27 04:19

    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.

    0 讨论(0)
提交回复
热议问题