logankilpatrick
logankilpatrick

Reputation: 14561

Error defining a struct in Julia: syntax: invalid type signature around REPL[2]:1

I am trying to define a struct in Julia as follows:

julia> struct
           myName::String
       end
ERROR: syntax: invalid type signature around REPL[2]:1
Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

however I am getting the error shown above. Any suggestions to resolve this?

Upvotes: 0

Views: 761

Answers (1)

logankilpatrick
logankilpatrick

Reputation: 14561

Silly me, the issue is the struct requires a name which I did not specific. I needed to do something like this:

julia> struct person
           myName::String
       end

which resolves the issue.

Upvotes: 1

Related Questions