A by-name parameter does the same thing as the previous koan but there is no need to explicitly handle Unit
or ()
.
A by-name parameter does the same thing as the previous koan but there is no need to explicitly handle Unit
or ()
. This is used extensively in Scala to create blocks:
() => Int
is a Function type that takes a Unit
type.
() => Int
is a Function type that takes a Unit
type. Unit
is known as void
to a Java programmer. The function returns an Int
. You can place this as a method parameter so that you can you use it as a block, but still it doesn't look quite right:
By name parameters can also be used with object
and apply
to make interesting block-like calls:
The parameterless execute method has been deprecated and will be removed in a future version of ScalaTest. Please invoke execute with empty parens instead: execute().
The trap method is no longer needed for demos in the REPL, which now abreviates stack traces, and will be removed in a future version of ScalaTest