This file contains hidden or 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
pragma solidity ^0.5.3; | |
contract Mapping { | |
mapping(address => uint[]) scores; | |
function manipulateArrayMap() external { | |
scores[msg.sender].push(1); //assign a value; | |
scores[msg.sender].push(2); //assign another element | |
This file contains hidden or 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
pragma solidity ^0.5.3; | |
contract Mapping { | |
mapping(address => uint) balances; | |
function manipulateMap() external { | |
balances[msg.sender] = 100; //assign a value; | |
balances[msg.sender] //read a value; |
This file contains hidden or 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
pragma solidity ^0.5.3; | |
contract ArraySolidity { | |
/** Visible external */ | |
function functionExternal(uint[] calldata myArg) external returns(uint[] memory) { | |
uint[] memory newArray = new uint[](10); | |
newArray[0] = 1; | |
This file contains hidden or 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
pragma solidity ^0.5.3; | |
contract MemoryArray { | |
/** | |
* These are temporary arrays and only exists when you are executing a function | |
* Must have a fixed size and must be declared inside a function | |
* You cannot run a for loop in a memory array | |
*/ | |
function memoryArray() public { | |
uint[] memory newArray = new uint[](10); |
This file contains hidden or 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
pragma solidity ^0.5.3; | |
contract{ | |
uint[] myArray; | |
function manipulateArray() external { | |
myArray.push(1); // add an element to the array | |
myArray.push(3); // add another element to the array | |
myArray[0]; // get the element at key 0 or first element in the array |
This file contains hidden or 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
pragma solidity ^0.5.3; | |
contract Array { | |
uint[] intergerArray; //sample showing initialization of an array of integers | |
bool[] boolArray; //sample showing initialization of an array of booleans | |
address[] addressArray; //sample showing initialization of an array of address etc. | |
} |
This file contains hidden or 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
renderPageNumbers = pageNumbers.map(number => { | |
let classes = this.state.current_page === number ? styles.active : ''; | |
if (number == 1 || number == this.state.total || (number >= this.state.current_page - 2 && number <= this.state.current_page + 2)) { | |
return ( | |
<span key={number} className={classes} onClick={() => this.makeHttpRequestWithPage(number)}>{number}</span> | |
); | |
} | |
}); |
This file contains hidden or 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
import React, { Component } from 'react'; | |
import styles from './App.module.css'; | |
class App extends Component { | |
state = { | |
users: null, | |
total: null, | |
per_page: null, |
This file contains hidden or 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
<div className={styles.pagination}> | |
<span onClick={() => this.makeHttpRequestWithPage(1)}>«</span> | |
{renderPageNumbers} | |
</div> |
This file contains hidden or 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
renderPageNumbers = pageNumbers.map(number => { | |
let classes = this.state.current_page === number ? styles.active : ''; | |
return ( | |
<span key={number} className={classes} onClick={() => this.makeHttpRequestWithPage(number)}>{number}</span> | |
); | |
}); |