Nvm, totally doesn't work for me.

On Sunday, June 14, 2015 at 7:40:56 AM UTC-4, Simon Danisch wrote:
>
> Julia is not object oriented, so you only put constructors inside the type 
> definition, which are then inner constructors.
> Inner constructors overwrite the default constructor, so the function 
> boss() replaces foo(::Int64).
> What you probably want is:
> type foo
>   a::Int
> end
> function boss(::foo)
>     println("Hey, boss!")
> end
> 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