Because Suit is the **first** field to Card........? i.e. you need push!(deck, Card(Suit(s), n))
-Jacob On Mon, Oct 3, 2016 at 9:55 PM, <[email protected]> wrote: > Ran into this while writing a simple, contrived example for a tutorial. > Still working on it but I am baffled. Can anyone tell me why this is > happening? > > *julia> **@enum Suit hearts=1 diamonds=2 clubs=3 spades=4* > > *julia> **type Card* > > * suit::Suit* > > * number::Int64* > > *end* > > *julia> **function newDeck()* > > * deck = Card[]* > > * for s = 1:4* > > * for n = 1:14* > > * push!(deck, Card(n, Suit(s)))* > > * end* > > * end* > > * deck* > > *end* > > *newDeck (generic function with 1 method)* > > > > *julia> **newDeck()* > > *ERROR: ArgumentError: invalid value for Enum Suit: 5* > > * in enum_argument_error at Enums.jl:27* > > * in convert at Enums.jl:79* > > * in newDeck at none:6* > > >
