Lesson 3: 03:15:42 confusion with syntax #2860
-
Lookin for some guidance with about a minute worth of video and a line of the code. In the intial example, when Patrick was saving instances of the simplestorage contract into a variable, he did it like this:
I get this, putting the contract in a variable. But then to create an array to allow all instances of SimpleStorage.sol to be put into a variable, he uses:
I don't get |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
@3toe : Let me clear this line and function in easy terms : The public function It creates a variable called It does this with the In the second line, it pushes this new contract into the |
Beta Was this translation helpful? Give feedback.
-
Hey @3toe the line |
Beta Was this translation helpful? Give feedback.
Hey @3toe the line
SimpleStorage simpleStorage = new SimpleStorage();
simply does whatsimpleStorage = new SimpleStorage();
does which creates a new instance ofSimpleStorage
. The only difference here is that we append the typeSimpleStorage
. This type is similar to how we writeuint256
orint
orbool
. So answer your question, whatSimpleStorage
does in that line is specify the type of the contact instance we are creating