Functions can have default arguments, as shown for the value argument of the compute function.
函数可以有默认参数,如compute函数的值参数所示。
Named and default arguments work hand in hand; one can pick a certain parameter by its name and use defaults for the others
具名与默认参数经常搭配使用,我们可以根据参数名称为参数赋值,同时对其他参数使用默认值,如下代码片段所示
Scala 2.8 also offers new language features, like the new named and default arguments. Named arguments look like assignments to the names of the called method's formal parameters
Scala 2.8还增加了新的语言特性,如新的具名与默认参数。
We'll see another useful example of named and default arguments when we discuss case classes in the section called "case classes" in Chapter 6, Advanced Object-Oriented Programming in Scala.
我们会在《第6章-Scala高级面向对象编程》中的“CaseClass(案例类)”中看到另外一个使用命名参数和默认参数的例子。
Is there a way to have dynamic default arguments?
有没有办法动态的默认参数?
Having default arguments seems like a cool feature.
参数拥有默认值看起来很牛。
In the third pair, the parameter lists differ only in their default arguments.
在第三对中,形参列表只有默认实参不同。
Default arguments cannot be used to deduce a template argument.
无法使用默认参数推导出模板参数。
Default arguments are not allowed on an explicit specialization of a function template.
不允许在函数模板的显式专用化上使用默认参数。
Default arguments are arguments and are treated the same way as any other argument during function matching.
默认实参也是实参,在函数匹配过程中,它的处理方式与其他实参一样。
Default arguments on functions and methods greatly reduce the number of overloaded methods you need to create.
函数和方法的默认参数极大地减少了需要创建的重载方法数量。
Default arguments ordinarily should be specified with the declaration for the function and placed in an appropriate header.
通常,应在函数声明中指定默认实参,并将该声明放在合适的头文件中。
Note that you cannot supply request parameters in that fashion - pages will be invoked without (or with default) arguments.
注意,不能以这种方式提供请求参数—页面可以在没有参数的情况下调用(或使用默认参数)。
Note that you cannot supply request parameters in that fashion - pages will be invoked without (or with default) arguments.
注意,不能以这种方式提供请求参数—页面可以在没有参数的情况下调用(或使用默认参数)。
应用推荐