Skip to content

Instantly share code, notes, and snippets.

View agoiabel's full-sized avatar

Agoi Abel Adeyemi agoiabel

  • Aveiro Portugal
View GitHub Profile
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;
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);
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
@agoiabel
agoiabel / array_map.sol
Last active March 31, 2020 13:29
storage array initialisation
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.
}
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>
);
}
});
import React, { Component } from 'react';
import styles from './App.module.css';
class App extends Component {
state = {
users: null,
total: null,
per_page: null,
<div className={styles.pagination}>
<span onClick={() => this.makeHttpRequestWithPage(1)}>&laquo;</span>
{renderPageNumbers}
</div>
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>
);
});
<div className={styles.pagination}>
<span onClick={() => this.makeHttpRequestWithPage(1)}>1</span>
<span onClick={() => this.makeHttpRequestWithPage(2)}>2</span>
<span onClick={() => this.makeHttpRequestWithPage(3)}>3</span>
<span onClick={() => this.makeHttpRequestWithPage(4)}>4</span>
</div>
const renderPageNumbers = pageNumbers.map(number => {
let classes = this.state.current_page === number ? styles.active : '';
if (number == 1 || number == this.state.meta.total || (number >= this.state.current_page - 2 && number <= this.state.current_page + 2)) {
return (
<span className={classes} onClick={() => this.makeHttpRequestWithPage(number)}>{number}</span>
);
}
});