Skip to content

Commit

Permalink
Add support for nothing
Browse files Browse the repository at this point in the history
I have been using this quite often to conditionally drop specific parameters.
  • Loading branch information
simsurace authored Feb 5, 2024
1 parent 1fdb2cb commit 6894f28
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/flatten.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ function flatten end

flatten(x) = flatten(Float64, x)

function ParameterHandling.flatten(::Type{T}, ::Nothing) where {T<:Real}
v = T[]
unflatten_to_Nothing(::Vector{T}) = nothing
return v, unflatten_to_Nothing
end

function flatten(::Type{T}, x::Integer) where {T<:Real}
v = T[]
unflatten_to_Integer(v::Vector{T}) = x
Expand Down

0 comments on commit 6894f28

Please sign in to comment.