From daee243c7ab8c019903bbc48b891ae2b8a44e653 Mon Sep 17 00:00:00 2001 From: Jeffrey Sarnoff Date: Tue, 19 Mar 2019 23:23:46 -0400 Subject: [PATCH] tryparse with nothing --- src/type/parse.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/type/parse.jl b/src/type/parse.jl index 43e4f277..a30a05c8 100644 --- a/src/type/parse.jl +++ b/src/type/parse.jl @@ -64,16 +64,16 @@ macro d16_str(val::AbstractString) end function tryparse(::Type{DoubleFloat{Float64}}, str::S; base::Int=10) where {S<:AbstractString} - bf = tryparse(BigFloat, str, base=base) - return DoubleFloat{Float64}(bf) + x = tryparse(BigFloat, str, base=base) + return ifelse(isnothing(x), nothing, DoubleFloat{Float64}(x)) end function tryparse(::Type{DoubleFloat{Float32}}, str::S; base::Int=10) where {S<:AbstractString} - bf = tryparse(BigFloat, str, base=base) - return DoubleFloat{Float32}(bf) + x = tryparse(BigFloat, str, base=base) + return ifelse(isnothing(x), nothing, DoubleFloat{Float32}(x)) end function tryparse(::Type{DoubleFloat{Float16}}, str::S; base::Int=10) where {S<:AbstractString} - bf = tryparse(BigFloat, str, base=base) - return DoubleFloat{Float16}(bf) + x = tryparse(BigFloat, str, base=base) + return ifelse(isnothing(x), nothing, DoubleFloat{Float16}(x)) end