0

When I'm creating structs, and those structs contain various types of variables, uint, string etc. Should i declare the visibility and if constant on those variables like with state variables?

0

You can only declare the visibility/constant of state variables, struct are members and you cannot declare their visibility.

struct S {
    uint a;
    bytes b;
    string s;
    // uint public v;  // <--- this fails to compile
}

But you can instantiate a struct variable and declare visibility

S public x;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.