This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier:MIT | |
pragma solidity ^0.8.7; | |
contract Smapping{ | |
//mapping | |
//mapping(keytype => vauletype)visibility identifier; // similar to array , can get value with index number here you can get value with key which you assign for value | |
// you can add more values | |
mapping(uint => mapping (uint => string)) person; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier:MIT | |
pragma solidity ^0.8.7; | |
contract arrays{ | |
uint[] public numbers = [1, 2, 3]; //dynamic array size not fixed | |
int [3] public intnum = [-2, 3, 4]; // integers must be with -ve value in arrays | |
// fixed Size array and dynamic | |
// push (add value in array) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier:MIT | |
pragma solidity ^0.8.7; | |
contract simfun{ | |
string public constant name = "Sam"; // used constant to use pure in funtion if it is public then we can remove constant | |
//function identifier() public view /pure returns(){ return name;} | |
function fun()public pure returns(string memory) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier:MIT | |
//This Program is about to understand datatypes in solidity | |
pragma solidity ^0.8.7; | |
contract Simple{ | |
//int, uint, string, address, bool | |
int public num = 369; | |
uint private unum = 7; //no -ve value or 0 allowed | |
string public nam = "sam"; |