Does anyone know why this stretch is giving error?
´´´
struct lis
it = zeros(Int8, 10)
beg::Int8
en::Int8
tot::Int8
end
´´´
Thanks!
Does anyone know why this stretch is giving error?
´´´
struct lis
it = zeros(Int8, 10)
beg::Int8
en::Int8
tot::Int8
end
´´´
Thanks!
First, please surround your code with triple backticks.
Second, you cannot have variable assignments within a struct. The error message you get tells you this:
ERROR: syntax: "it = zeros(Int8, 10)" inside type definition is reserved
If you need this data inside a struct, create a field it::Vector{Int8}
and then initialize the struct with lis(zeros(Int8, 10), ...)
.
Probably useful: Default value of *some* fields in a mutable struct.
See also Parameters.jl which allows you to set default values for fields.
Hello! thanks for the tip. The way I want to manipulate the struct, using hectorogen values, is giving this error.
struct lis
it::Vector{Int8}
beg::Int8
en::Int8
tot::Int8
end
ERROR: invalid redefinition of constant lis
Stacktrace:
[1] top-level scope at none:0
You probably defined it before. You can only redefine a struct
after restarting Julia.