from http://docs.julialang.org/en/latest/manual/constructors/
...This automatic provision of constructors is equivalent to the following
explicit declaration:
type Point{T<:Real}
>
> x::T
>
> y::T
>
>
>> Point(x,y) = new(x,y)
>
> end
>
>
>> Point{T<:Real}(x::T, y::T) = Point{T}(x,y)
>
>
I've been bitten by this many times and see so many others being bitten. I
know the docs explain this as well as I could, but it would be great if
someone could come up with some educational magic to improve the docs a bit
more.
On Saturday, June 4, 2016 at 10:17:16 AM UTC+8, David P. Sanders
El viernes, 3 de junio de 2016, 22:06:20 (UTC-4), xdavidliu escribió:
>
> with
>
>
> type foo
> x::Int
> foo(x) = x > 0 ? new(x) : new(-x)
> end
>
>
> type bar{T<:Integer}
> x::T
> end
>
>
> type baz{T<:Integer}
> x::T
> baz(x) = x > 0 ? new(x) : new(-x)
> end
>
>
>
>