schweitzer.philip
2 months ago  Karma: -6
How to pass an unknown number of elements to a function (or pass a 2d array)

I've been racking my brain on a problem all day, and the only ways I can think of to solve it are either by passing an unknown number of elements into a function, or to pass a 2d array in (I'm partial to having a function that can accept any number of elements).

Essentially, I have a 5x5 grid of items and I need a way to access multiples of them in tandem and change them all equally.

Does anyone have any tips here?

en
#solidity
solidity
#Suggestion
#learn
schweitzer.philip
2 months ago  Karma: -6
How to pass an unknown number of elements to a function (or pass a 2d array)

I've been racking my brain on a problem all day, and the only ways I can think of to solve it are either by passing an unknown number of elements into a function, or to pass a 2d array in (I'm partial to having a function that can accept any number of elements).

Essentially, I have a 5x5 grid of items and I need a way to access multiples of them in tandem and change them all equally.

Does anyone have any tips here?

en
#solidity
solidity
#Suggestion
#learn

ONE ANSWER
jeff.larkin49
2 months ago Karma: 10

I'm not sure I fully understand what you're trying to achieve. Are you saying that you have 25 items (5x5) in all and some subset of them needs to be updated, but the number may vary from call to call? Before making suggestions, do I understand the gist of your problem? Is the same update applied to all of the objects that require updating?

I'm not sure I fully understand what you're trying to achieve. Are you saying that you have 25 items (5x5) in all and some subset of them needs to be updated, but the number may vary from call to call? Before making suggestions, do I understand the gist of your problem? Is the same update applied to all of the objects that require updating?

schweitzer.philip

You've got it exactly right :)

Mar 15 '19 at 3:26 pm
Earn tokens by posting and answering questions about blockchain!
Karma to eth
YOUR ANSWER