Julia 1.7 added the Returns()
function which is described as:
Create a callable
f
such thatf(args...; kw...) === value
holds.
However, you can get the same results with a regular function that accepts any arguments:
f1 = Returns(99)
f2(args... ; kwargs...) = return 99
f1() === f2() # true
f1("this", 1) === f2("that", 2) # true
Is there some other purpose for Returns()
other than being a shortcut for creating a function that returns a fixed result? The PDF documentation doesn't explain Returns()
at all.