REPL and Source Code Question

Hello,

Often times when I am exploring and building things with a new package I am frequently checking what methods are available in the REPL by doing ? SomeFunc. It will return something like # 3 methods for generic function blah and then show a list of them with the corresponding line numbers in the source.

If there is a specific method I want to see the source for, is it possible print it out in the REPL? If so what command is used?

Check out methods(), edit() and @edit. They’re super handy!

julia> methods(println)
# 3 methods for generic function "println":
[1] println(io::IO) in Base at coreio.jl:5
[2] println(io::IO, xs...) in Base at strings/io.jl:73
[3] println(xs...) in Base at coreio.jl:4

julia> ans[3]
println(xs...) in Base at coreio.jl:4

julia> edit(ans) # opens file at relevant line in text editor

Or more breifly,

julia> @edit println("this opens", [:the, :source], "in an editor")
1 Like