How do you create an instance of type BadInt then?
On Wednesday, December 9, 2015 at 7:01:25 AM UTC-5, milktrader wrote: > > Trying to wrap my mind around singleton types to see if they might be > useful for something I'm working on, but running into some confusion. Here > is an example that I started working with: > > julia> type BadInt > end > > julia> import Base.+ > > julia> +(x::BadInt, y::Int64) = x - y > + (generic function with 172 methods) > > julia> BadInt() = 2 > BadInt > > julia> BadInt + 2 > ERROR: MethodError: `+` has no method matching +(::Type{BadInt}, ::Int64) > Closest candidates are: > +(::Any, ::Any, ::Any, ::Any...) > +(::Int64, ::Int64) > +(::Complex{Bool}, ::Real) > ... > > As I understand, a singleton type can only take on a single value. What's > the utility in supporting this? >