Stream: helpdesk (published)

Topic: ✔ Seeking API Design Advice for Setting Defaults


view this post on Zulip Sundar R (Dec 15 2024 at 16:06):

One easy way would be to change the type of visuals in the struct to be visuals::Union{Vector{Dict}, Nothing}, change its default value in the constructor to be visuals=nothing, and then in the individual visualize methods (in SMA.jl, HMA.jl, etc.), instead of

    defaults = Dict(
# ...
    )
    kwargs = merge(defaults, Dict(opts))

do it as

    kwargs = Dict(
# ...
    )
    if opts !== nothing
        merge!(kwargs, Dict(opts))
    end

view this post on Zulip G Gundam (Dec 15 2024 at 16:18):

I like that. That's pretty straightforward. Thanks for taking the time to look into that.

view this post on Zulip G Gundam (Dec 16 2024 at 04:02):

It ended up working pretty well. Thanks again, @Sundar R .

view this post on Zulip Notification Bot (Dec 16 2024 at 04:02):

G Gundam has marked this topic as resolved.


Last updated: Jan 29 2025 at 04:38 UTC