The chapter on constructor may be even more relevant:

http://julia.readthedocs.org/en/release-0.3/manual/constructors/

On Mon, Jun 15, 2015 at 5:06 AM, Simon Danisch <[email protected]> wrote:

> Yeah, I know it does. But it does not do what you think it does. That's
> what I was trying to point out.
> Please consider reading the docs, especially the chapter types:
> http://julia.readthedocs.org/en/release-0.3/manual/types/
>
> Am Sonntag, 14. Juni 2015 13:26:28 UTC+2 schrieb Ranjan Anantharaman:
>
>> Hello,
>>
>> How do I initialize this composite type in Julia?
>>
>> type foo
>>   a::Int64
>>   function boss()
>>     println("Hey, boss!")
>>   end
>> end
>>
>> If I do f = foo(1), then I get the following error:
>>
>> ERROR: MethodError: `convert` has no method matching convert(::Type{foo},
>> ::Int64)
>> This may have arisen from a call to the constructor foo(...),
>> since type constructors fall back to convert methods.
>> Closest candidates are:
>>   call{T}(::Type{T}, ::Any)
>>   convert{T}(::Type{T}, ::T)
>>  in call at base.jl:40
>>
>> How do I create an object of type foo?
>>
>> Thanks in advance.
>>
>

Reply via email to