@Simon that was my original thought, too. But, this actually works for me:

julia> type foo
         a::Int64 
         function boss() 
           println("Hey, boss!") 
         end 
       end 

julia> f = foo(1) 
foo(1)


@Ranjan, what version of Julia are you using?
On Sunday, June 14, 2015 at 7:26:28 AM UTC-4, Ranjan Anantharaman wrote:
>
> 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