What's the appropriate way to update a struct via a function only if the parameters exist? For example
struct MyStruct {
bytes32 someThing
bytes32 someOtherThing
}
function updateStruct(bytes32 someThing, bytes32 someOtherThing) public {
// get struct
if (someThing) {
struct.someThing = someThing;
}
if(someOtherThing) {
struct.someOtherThing;
}
}
I only want to update the fields of the struct if the argument is passed into the function. If it's null
or undefined
I don't want to update the struct with that value.
somethig.length>0
for your if condition.If it's null or undefined
- this is not Javascript.