I recently came across that splatting types into outer constructors works fine:
julia> struct Foo{A,B}
a
b
end
julia> function Foo(a,b)
args = (a, b)
return Foo{typeof.(args)...}(args...)
end
Foo
But splatting types into the inner constructor (new{}
) fails:
julia> struct Foo{A,B}
a
b
function Foo(a,b)
args = (a, b)
return new{typeof.(args)...}(args...)
end
end
ERROR: syntax: too few type parameters specified in "new{...}" around REPL[1]:1
Stacktrace:
[1] top-level scope at REPL[1]:1
Ok, good news. I think we can just remove this error check.
Most helpful comment
Ok, good news. I think we can just remove this error check.