Skip to content

Tuple constructor change from 0.5 to 0.6 #20969

@sbromberger

Description

@sbromberger

0.5:

julia> immutable Edge
           src::Int
           dst::Int
       end

julia> src(e::Edge) = e.src
src (generic function with 1 method)

julia> dst(e::Edge) = e.dst
dst (generic function with 1 method)

julia> import Base.convert

julia> convert(::Type{Tuple}, e::Edge) = (src(e), dst(e))
convert (generic function with 597 methods)

julia> e = Edge(1,2)
Edge(1,2)

julia> Tuple(e)
(1,2)

0.6:

julia> struct Edge
         src::Int
         dst::Int
       end

julia> src(e::Edge) = e.src
src (generic function with 1 method)

julia> dst(e::Edge) = e.dst
dst (generic function with 1 method)

julia> import Base.convert

julia> convert(::Type{Tuple}, e::Edge) = (src(e), dst(e))
convert (generic function with 700 methods)

julia> e = Edge(1,2)
Edge(1, 2)

julia> Tuple(e)
ERROR: MethodError: no method matching start(::Edge)
Closest candidates are:
  start(::SimpleVector) at essentials.jl:259
  start(::Base.MethodList) at reflection.jl:559
  start(::ExponentialBackOff) at error.jl:107
  ...
Stacktrace:
 [1] Tuple(::Edge) at ./tuple.jl:198

Not sure whether I missed something in NEWS again, but here we are.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions