Julia 如何获取类型的所有方法
我有一个类型Julia 如何获取类型的所有方法,julia,Julia,我有一个类型T,如何在REPL中获得所有专用于此类型的方法?我的动机是T是在一个包中定义的,从源代码中可能不容易看出我打算用T做什么 总之,我想要的是 functions(T) 由于方法已经存在,但它需要我想要了解的函数您需要使用方法与(T): 任何人都可以指定语法来列出“示例”模块中的所有可用方法,或者使用Pkg.add(“模块名称”)从外部源安装的任何模块? help?> methodswith search: methodswith methodswith(typ[, mod
T
,如何在REPL中获得所有专用于此类型的方法?我的动机是T
是在一个包中定义的,从源代码中可能不容易看出我打算用T
做什么
总之,我想要的是
functions(T)
由于
方法
已经存在,但它需要我想要了解的函数您需要使用方法与(T)
:
任何人都可以指定语法来列出“示例”模块中的所有可用方法,或者使用Pkg.add(“模块名称”)从外部源安装的任何模块?
help?> methodswith
search: methodswith
methodswith(typ[, module or function][, showparents])
Return an array of methods with an argument of type typ. If optional showparents
is true, also return arguments with a parent type of typ, excluding type Any.
The optional second argument restricts the search to a particular module or
function.
julia> type Foo end
julia> methodswith(Foo)
0-element Array{Method,1}
julia> foo(::Foo) = nothing
foo (generic function with 1 method)
julia> methodswith(Foo)
1-element Array{Method,1}:
foo(::Foo) at none:1