What new() in inner costructor do?

raman_kumar
Fri, 17 Oct 2025 22:55:47 +0000
New to Julia

What does new in general do in inner constructor? For example in this code in documentation how new know the work( here create instance if x>y) it should do? Constructors · The Julia Language

julia> struct OrderedPair
           x::Real
           y::Real
           OrderedPair(x,y) = x > y ? error("out of order") : new(x,y)
       end

What are the advantages of using inner constructor?

6 posts - 4 participants