try this: type LoHiPair{T<:Real} lo::T hi::T
function LoHiPair{A}(lo::A, hi::A) if lo > hi throw( error("out of order") ) end new(lo, hi) end end LoHiPair{T<:Real}(lo::T, hi::T) = LoHiPair{T}(lo, hi) On Tuesday, April 26, 2016 at 3:57:59 PM UTC-4, CrocoDuck O'Ducks wrote: > > Hi there! > > I was reading this > <http://docs.julialang.org/en/release-0.4/manual/constructors/#inner-constructor-methods> > > and trying the code, which I saved into a file called test.jl: > > type OrderedPair > x::Real > y::Real > > OrderedPair(x,y) = x > y ? error("out of order") : new(x,y) > end > > > If I use lintfile("test.jl") I get this: > > ConstrTest.jl:5 E611 : constructor doesn't seem to return the constructed > object > > I am implementing a similar constructor for a project of mine and I was > wondering whether, in general, the use of error() in the constructor is > good practice or if I should prefer other ways to solve the problem. >