the argument
Returns the result of invoking the function f, passed to the LazyArg
constructor, on field arg.
Returns the result of invoking the function f, passed to the LazyArg
constructor, on field arg.
Transforms a given object's
toStringwith a given function lazily.This class is intended to be used with the
mapResultmethod ofMatcherProducers, which you can use to modify error messages when composing matchers. This class exists to enable those error messages to be modified lazily, so thattoStringis invoked on the givenarg, and its result transformed by the given functionf, only when and if thetoStringmethod is invoked on theLazyArg. As a performance optimization, ScalaTest'sMatchResultavoids invokingtoStringon objects until and unless an error message is actually needed, to minimize unecessary creation and concatenation of strings. TheLazyArgclass enables this same performance optimization when composing matchers.The other design goal of
LazyArgis to make the internalargavailable for inspection in an IDE. In a future version of ScalaTest, theargsofMatchResultthat were used to create the error message will be included in theTestFailedException, so they can be inspected in IDEs. This is why theargfield ofLazyArgis public.For an example of using
LazyArg, see the Composing matchers section in the main documentation for traitMatcher.the argument
a function that given the
argwill produce aString