Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird constructor for type alised Dict #3215

Closed
KristofferC opened this issue Oct 3, 2022 · 1 comment · Fixed by #3261
Closed

Weird constructor for type alised Dict #3215

KristofferC opened this issue Oct 3, 2022 · 1 comment · Fixed by #3261

Comments

@KristofferC
Copy link
Member

Happened to see this:

const APIOptions = Dict{Symbol, Any}
function APIOptions(options::Vector{Option},
specs::Dict{String, OptionSpec},
)::APIOptions
api_options = Dict{Symbol, Any}()
enforce_option(options, specs)
for option in options
spec = specs[option.val]
api_options[spec.api.first] = spec.takes_arg ?
spec.api.second(option.argument) :
spec.api.second
end
return api_options
end

This is not great, it adds a constructor to a certain type of dictionary. This should likely just be its own type.

@KristofferC
Copy link
Member Author

Same with

const PackageToken = Union{PackageIdentifier, VersionToken, Rev, Subdir}

PackageToken(word::String)::PackageToken =
first(word) == '@' ? VersionToken(word[2:end]) :
first(word) == '#' ? Rev(word[2:end]) :
first(word) == ':' ? Subdir(word[2:end]) :
String(word)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant