Why am I not able to assign a value to a mutable struct field if I have not restricted it to a particular type for the following case:
mutable struct TestStruct
field1
field2
function TestStruct(field1)
new(field1, nothing)
end
end
TestStruct(10) #returns TestStruct(12, nothing) as expected
TestStruct(10, 20) #throws method error: no method matching TestStruct(::Int64, ::Int64)
Can someone explain what’s wrong with creating the object the second way? I am pretty sure it’s something naive but I fail to understand it. Thank you!