gpt4 book ai didi

julia - 如何在 Julia Base 中找到抽象类型的子类型?

转载 作者:行者123 更新时间:2023-12-05 00:49:01 25 4
gpt4 key购买 nike

例如,假设我为AbstractFloat写了一个函数,我想知道这个方法定义的影响,如何查看Base中AbstractFloat的所有子类型?

最佳答案

您正在寻找 subtypes :

Return a list of immediate subtypes of DataType T. Note that all currently loaded subtypes are included, including those not visible in the current module.

julia> subtypes(AbstractFloat)
4-element Array{Union{DataType, UnionAll},1}:
BigFloat
Float16
Float32
Float64

但有趣的是,Base中只有一个:

julia> subtypes(Base, AbstractFloat)
1-element Array{Union{DataType, UnionAll},1}:
BigFloat

顺便说一句,PlotRecipes.jl 中有一个不错的食谱可视化类型树: enter image description here

关于julia - 如何在 Julia Base 中找到抽象类型的子类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46851485/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com