I want to run a code for each of a certain value in a array... I can show an example of what I need like this;
My_Garden = [Apple, Apple, Apple, Pumpkin, Pear];My_Pocket = Array.newfor each Apple in My_Garden My_Pocket.push(Apple)endFrom the example above I want it to work like that Push as many apples as their are in My_Garden to My_Pocket.
another example
My_Offenses = [Stealing, Stealing, Stealing]for each Stealing in My_Offenses getArrested()endIn this example I would get arrested 3 times, XD (Just an example)
Basically, I want to run a code x times, when x = the amount of a certain object.
I am new to Ruby didn't cover it in school, and rarely used in the work place so any help is greatly appreciated, thanks in advance
My_Garden = [Apple, Apple, Apple, Pumpkin, Pear];My_Pocket = Array.newfor each Apple in My_Garden My_Pocket.push(Apple)endFrom the example above I want it to work like that Push as many apples as their are in My_Garden to My_Pocket.
another example
My_Offenses = [Stealing, Stealing, Stealing]for each Stealing in My_Offenses getArrested()endIn this example I would get arrested 3 times, XD (Just an example)
Basically, I want to run a code x times, when x = the amount of a certain object.
I am new to Ruby didn't cover it in school, and rarely used in the work place so any help is greatly appreciated, thanks in advance