Skip to content

Instantly share code, notes, and snippets.

@fassko
Created August 30, 2022 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fassko/86af7e7598ae950ad5ed2fdba7b66309 to your computer and use it in GitHub Desktop.
Save fassko/86af7e7598ae950ad5ed2fdba7b66309 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "hardhat/console.sol";
enum EmployeeType {
Employee,
Contractor,
PartTime
}
struct Person {
EmployeeType employeeType;
bool deleted;
string name;
uint256 yearOfBirth;
address walletAddress;
uint256[] doorAccess;
}
contract AbsenceOfNull {
Person person;
function print() external view returns(Person memory) {
console.log("Person:");
console.log(" deleted", person.deleted);
console.log(" name", person.name);
console.log(" name lenght", bytes(person.name).length);
console.log(" yearOfBirth", person.yearOfBirth);
console.log(" walletAddress", person.walletAddress);
return person;
}
function check() external view {
console.log("Deleted", person.deleted == false);
console.log("Name", bytes(person.name).length == 0);
console.log("Year of birth", person.yearOfBirth == 0);
console.log("Wallet address", person.walletAddress == address(0));
console.log("Employee type", person.employeeType == EmployeeType.Employee);
console.log("Door access", person.doorAccess.length == 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment