Linked Questions
11 questions linked to/from What is the zero, empty or null value of a struct?
2
votes
1
answer
3k
views
How to find out whether an address is already in the mapping [duplicate]
If I have a mapping like this
struct data {
string name;
string nickname;
}
mapping(address => data) public user;
How can I find out whether an address is already in the mapping or ...
1
vote
0
answers
2k
views
How can I check if a variable or an array is set or empty or null? [duplicate]
How can I check if a variable or an array is already set, empty or null in solidity?
For example,
mapping (string => address) addresses;
How can we know addresses[key] is set or not?
2
votes
0
answers
1k
views
What returns mapping if key not exist? [duplicate]
For example, i have:
mapping(string => MyType) map;
var value = map[key];
What is equal 'value' if 'map' not contain the 'key'?
And how to determine the presence of the key in mapping?
3
votes
0
answers
1k
views
Checking for empty mapping element [duplicate]
What is the best way to know if an element is " empyt " inside a mapping ?
For example
mapping ( address => uint) balances;
If the user already used the contract there will be an address => "...
21
votes
2
answers
7k
views
What is the zero value for a string?
How to verify that a string, or a struct with only string properties, is initialised or not, inside of a mapping?
According to the docs, it means checking that the element of the mapping is at its 0-...
6
votes
3
answers
9k
views
Default value of a struct
Consider the following contract in Solidity:
pragma solidity ^0.4.2;
contract Registry {
struct Name {
string first;
string last;
}
mapping(address => Name) reg;
...
8
votes
1
answer
3k
views
Checking zero value of structure
I have the following statements:
Voter sender = voters[msg.sender];
if (!sender || sender.voted) throw;
I'm new to solidity, so I might not be aware of how (or if) coercion works.
As I found out in ...
12
votes
1
answer
4k
views
How to test if a struct state variable is set
I have the following struct defined as a state variable and conditionally set at runtime.
Transaction private tx;
struct Transaction {
address to;
uint value;
bytes data;
}
I would like ...
5
votes
2
answers
5k
views
Mapping member isn't initialized when creating a struct
pragma solidity ^0.4.0;
contract TestcaseResetObject {
MyObject ob;
struct MyObject {
mapping(uint8 => uint) map;
}
event Output(uint number);
function makeNew() {
...
4
votes
2
answers
838
views
Throw not generated when accessing mapping with invalid key
I'm trying to implement the current contract:
contract Mortal {
address owner;
event Killed(address indexed from);
function Mortal() {
owner = msg.sender;
}
function ...
1
vote
1
answer
347
views
How do I check If a map entry doesn't exist for a given sender?
I have a map such as:
mapping (address => bytes32) private myMap;
Later in the code, in a function, I want to ensure my sender already has an entry in that given map.
Can I do this?
require(!...