julia> type A{T}
item::Nullable{T}
function A()
new(Nullable{T}())
end
end
julia> A{Int}()
A{Int64}(Nullable{Int64}())
You only need the name, and it uses the parameters from the type definition.
On Tue, Sep 13, 2016 at 9:28 AM, SZubik <[email protected]> wrote:
> Hi,
>
> For some reason I can't figure out the following, maybe someone
> encountered this before.
> For example I have the following type
>
> type A{T}
> item::Nullable{T}
> end
>
> and
>
> A{Int64}(2)
>
> returns A{Int64}(Nullable{2}) as expected.
>
> However I want to introduce a constructor with no parameters (so by
> default item is null):
>
> type A{T}
> item::Nullable{T}
> function A{T}()
> new{T}(Nullable{T}())
> end
> end
>
> And I get
>
> WARNING: static parameter T does not occur in signature for call at line 4
> The method will not be callable.
>
>
> As expected, I get some error when try to call it:
>
> A{Int64}()
>
> Error:
>
> LoadError: MethodError: `convert` has no method matching
> convert(::Type{A{Int64}})
> This may have arisen from a call to the constructor A{Int64}(...),
> since type constructors fall back to convert methods.
>
>
> If someone could help me make sense out of this, it would be much appreciated
> :)
>
> Thanks
>
>
>