I want to do something like this
type Struct1 {
a string
}
type Struct 2{
b int
}
if something{
c := Struct1{a:''}
}else{
c := Struct2{b:1}
}
somefunc(c)
I know I can't declare c inside of one block and then access it outside.
I tried something like this
type Struct1 {
a string
}
type Struct 2{
b int
}
c := Struct2{b:1}
if something{
c := Struct1{a:''}
}
somefunc(c)
It gives error- Cannot assign Struct1 to c(type Struct2)
How can I achieve something like this?