How can user defined functions (say f
) have meaningful printouts when inspected via the REPL using ?f
or help(f)
For example imagine I write the following funciton
function f(x::Float64, y::Float64)
return 2x - y^2
end
If I load this into a julia session and try help(f)
I get the following:
julia> help(f)
f (generic function with 1 method)
What if instead I wanted to see something like
julia> help(f)
f
Compute 2 times x minus y squared
where the description "Compute 2 times x minus y squared" is written somewhere. I am guessing the answer to my question can be determined from the answer to the question "Where is the somewhere the description should be written?"
By way of example, if I wanted to do the same in python, I could define the function and put the description as a docstring:
def f(x, y):
"""
Compute 2 times x minus y squared
"""
return 2 * x - y ** 2
which would make my description immediately available when I type help(f)
or f?
from IPython.