A little doubt #3413
-
function callStoreFunction(uint256 _indexNumber, uint256 _simpleStorageNumber) public {
SimpleStorage simpleStorage = simpleStorageArray[_indexNumber];
simpleStorage.store(_simpleStorageNumber);
} In line 1 we are passing a parameter |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
@imhacek I think you are asking that we are not adding any condition here to check whether at this index contract exists or not. Am I correct? |
Beta Was this translation helpful? Give feedback.
-
Because the user, when seeking to use the functionality this function provides, will aptly provide the correct parameter. I.e. they will use the index in the first parameter here: An example to illustrate how this works: (Written in pseudo-code for illustration, ignore syntactical errors) library useFunction {
function sum(uint256 numberOne, uint256 numberTwo) returns(uint256){
memory uint256 total = 0;
total = numberOne + numberTwo;
return total
}
contract useLibrary {
// ignoring formalization of numbers...
using useFunction for uint256;
uint256 contractNumberOne = 4;
uint256 contractNumberTwo = 9;
function demonstrateConcept () returns(uint256) {
uint256 contractTotal;
contractTotal = sum(contractNumberOne, contractNumberTwo)
return contractTotal // returns sum, i.e. 13
}
}
}
|
Beta Was this translation helpful? Give feedback.
Because the user, when seeking to use the functionality this function provides, will aptly provide the correct parameter. I.e. they will use the index in the first parameter here:
callStoreFunction(uint256 _indexNumber, uint256 _simpleStorageNumber)
An example to illustrate how this works:
(Written in pseudo-code for illustration, ignore syntactical errors)