Skip to main content
Commonmark migration
Source Link

As far as I know, in Solidity there is no "null" equivalent. This means you need to get a bit clever with how you check for empty values.

bytes32 is really an array with a fixed length of 32. In order to check for an empty value here you can try the [following][1]following:

require(_name[0] != 0);

This will check whether or not the string being passed in is empty.

As for the uint, I made the following change in the XYZ contract:

uint public number;
...
number = _number;

Since public variables in Solidity have "built-in" getter functions I was able to check its value (after deploying it on Remix). It appears that it is initialized as 0. This means that as long as you consider 0 to be a valid value to be passed into ABC you don't even need to check whether or not _number is non-zero.

Hope that helps! [1]: https://ethereum.stackexchange.com/a/27229/20165

As far as I know, in Solidity there is no "null" equivalent. This means you need to get a bit clever with how you check for empty values.

bytes32 is really an array with a fixed length of 32. In order to check for an empty value here you can try the [following][1]:

require(_name[0] != 0);

This will check whether or not the string being passed in is empty.

As for the uint, I made the following change in the XYZ contract:

uint public number;
...
number = _number;

Since public variables in Solidity have "built-in" getter functions I was able to check its value (after deploying it on Remix). It appears that it is initialized as 0. This means that as long as you consider 0 to be a valid value to be passed into ABC you don't even need to check whether or not _number is non-zero.

Hope that helps! [1]: https://ethereum.stackexchange.com/a/27229/20165

As far as I know, in Solidity there is no "null" equivalent. This means you need to get a bit clever with how you check for empty values.

bytes32 is really an array with a fixed length of 32. In order to check for an empty value here you can try the following:

require(_name[0] != 0);

This will check whether or not the string being passed in is empty.

As for the uint, I made the following change in the XYZ contract:

uint public number;
...
number = _number;

Since public variables in Solidity have "built-in" getter functions I was able to check its value (after deploying it on Remix). It appears that it is initialized as 0. This means that as long as you consider 0 to be a valid value to be passed into ABC you don't even need to check whether or not _number is non-zero.

Hope that helps!

Source Link

As far as I know, in Solidity there is no "null" equivalent. This means you need to get a bit clever with how you check for empty values.

bytes32 is really an array with a fixed length of 32. In order to check for an empty value here you can try the [following][1]:

require(_name[0] != 0);

This will check whether or not the string being passed in is empty.

As for the uint, I made the following change in the XYZ contract:

uint public number;
...
number = _number;

Since public variables in Solidity have "built-in" getter functions I was able to check its value (after deploying it on Remix). It appears that it is initialized as 0. This means that as long as you consider 0 to be a valid value to be passed into ABC you don't even need to check whether or not _number is non-zero.

Hope that helps! [1]: https://ethereum.stackexchange.com/a/27229/20165