3
如果我定義了一個具有默認值的單個參數的方法,我可以在不傳遞任何參數的情況下調用它嗎?scala方法中的單個默認參數
scala> def printArgs(str:String = "default"){println(str)}
printArgs: (str: String)Unit
scala> printArgs
<console>:11: error: missing arguments for method printArgs in object $iw;
follow this method with '_' if you want to treat it as a partially applied function
printArgs
^
必須添加一個空白的括號()儘管在這種情況下它應該是'printArgs()' – aishwarya 2012-08-10 22:19:13