You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can I verify whether a specific field has a default value? I'm looking to dynamically construct a struct and configure it using a named tuple, but I want to do this only for fields that don't have predefined defaults.
@with_kwstruct Model
Lx::Int=128
Ly::Int=128
M::Matrixendfunctionhas_default(Model, fieldname)
# ....?endfunctioncreate(Model, settings)
defaults =Dict()
for (fieldname, fieldtype) inzip(fieldnames(Model), fieldtypes(Model))
if fieldtype == Matrix &&!has_default(Model, fieldname)
defaults[fieldname] =fieldtype(undef, settings.Lx, settings.Ly)
endendreturnModel(; settings..., defaults...)
end
The text was updated successfully, but these errors were encountered:
Can I verify whether a specific field has a default value? I'm looking to dynamically construct a struct and configure it using a named tuple, but I want to do this only for fields that don't have predefined defaults.
The text was updated successfully, but these errors were encountered: