How would I add a value to each element making it larger based on Array size?
Have a foreach loop on an array and would like to have a variable incremented for each individual array element but can't figure out where to do this at. When attempting to do it in the foreach loop it does to each item in the array. How do I go about adding a value to each element making it larger based on the array element.
Let me see if I understadn your question: Case1: You have an array of n elements. YOu are doing a for-each on this array. You want to increment a varibale (whcih is not a memerb of the array)in each loop iteration?
If this si your question, you can create an Int variable. Within the loop body, add 1 to this variable.
OR Case2: In each iteration you want to increment the array element in taht iteration. eg:
before: [1, 3, 5, 6, 9]
after: [2, 4, 6, 7, 10]
In this case you must add 1 to the curernt elemnt in question. You will get this as an output pin in the for-each loop.
Sorry if I mis-undertood.
answered Jul 11 '14 at 03:18 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here