Skip to main content
edited body
Source Link
Jesbus
  • 10.5k
  • 6
  • 38
  • 62

What does setting the length property of an array do.? In most other languages length is a function that return the length of an array.

I have the following code:

struct ledger_t {
  uint8 WinningNum1;
  uint8 WinningNum2;
  uint8 WinningNum3;
  uint8 WinningNum4;
  bytes32 ClosingHash;
  bytes32 OpeningHash;
  mapping(address=>bet_t) bets;
  uint Guess4OutOf4;
  uint Guess3OutOf4;
  uint Guess2OutOf4;
  uint Guess1OutOf4;
  uint PriceOfTicket;
  uint ExpirationTime; //for eventual refunds only, ~2 weeks after draw announced
}
ledger_t[] public ledger;

//constructor
function TheEthereumLottery() {
  owner = msg.sender;
  ledger.length = 0;
  IndexOfCurrentDraw = 0;
  referral_fee = 90;
}

What does setting the length property of an array do. In most other languages length is a function that return the length of an array.

I have the following code:

struct ledger_t {
  uint8 WinningNum1;
  uint8 WinningNum2;
  uint8 WinningNum3;
  uint8 WinningNum4;
  bytes32 ClosingHash;
  bytes32 OpeningHash;
  mapping(address=>bet_t) bets;
  uint Guess4OutOf4;
  uint Guess3OutOf4;
  uint Guess2OutOf4;
  uint Guess1OutOf4;
  uint PriceOfTicket;
  uint ExpirationTime; //for eventual refunds only, ~2 weeks after draw announced
}
ledger_t[] public ledger;

//constructor
function TheEthereumLottery() {
  owner = msg.sender;
  ledger.length = 0;
  IndexOfCurrentDraw = 0;
  referral_fee = 90;
}

What does setting the length property of an array do? In most other languages length is a function that return the length of an array.

I have the following code:

struct ledger_t {
  uint8 WinningNum1;
  uint8 WinningNum2;
  uint8 WinningNum3;
  uint8 WinningNum4;
  bytes32 ClosingHash;
  bytes32 OpeningHash;
  mapping(address=>bet_t) bets;
  uint Guess4OutOf4;
  uint Guess3OutOf4;
  uint Guess2OutOf4;
  uint Guess1OutOf4;
  uint PriceOfTicket;
  uint ExpirationTime; //for eventual refunds only, ~2 weeks after draw announced
}
ledger_t[] public ledger;

//constructor
function TheEthereumLottery() {
  owner = msg.sender;
  ledger.length = 0;
  IndexOfCurrentDraw = 0;
  referral_fee = 90;
}
Source Link
RFV
  • 633
  • 7
  • 16

setting the length property of array

What does setting the length property of an array do. In most other languages length is a function that return the length of an array.

I have the following code:

struct ledger_t {
  uint8 WinningNum1;
  uint8 WinningNum2;
  uint8 WinningNum3;
  uint8 WinningNum4;
  bytes32 ClosingHash;
  bytes32 OpeningHash;
  mapping(address=>bet_t) bets;
  uint Guess4OutOf4;
  uint Guess3OutOf4;
  uint Guess2OutOf4;
  uint Guess1OutOf4;
  uint PriceOfTicket;
  uint ExpirationTime; //for eventual refunds only, ~2 weeks after draw announced
}
ledger_t[] public ledger;

//constructor
function TheEthereumLottery() {
  owner = msg.sender;
  ledger.length = 0;
  IndexOfCurrentDraw = 0;
  referral_fee = 90;
}