Wikia

FiM++ Community Wiki

Changes: For

Edit

Back to page

(Created page with "== Syntax == === Counting === *{{codeblock|{{code|keyword|For every}}{{tag|whitespace}}{{tag|type|[number/character]}}{{tag|whitespace}}{{tag|variable|new name}}{{tag|whitespa...")
 
(Iterate through an array: much more natural wording)
 
Line 17: Line 17:
   
 
=== Iterate through an array ===
 
=== Iterate through an array ===
{{codeblock|{{code|keyword|Did you know that}}{{code|whitespace|&nbsp;}}{{code|variable|Berry Punch}}{{code|whitespace|&nbsp;}}{{code|keyword|likes}}{{code|whitespace|&nbsp;}}{{code|type|the phrase}}{{code|whitespace|&nbsp;}}{{code|literal|&ldquo;Cheerwine&rdquo;}}{{code|punctuation|?}}{{code|whitespace|<BR/>}}{{code|keyword|For every}}{{code|whitespace|&nbsp;}}{{code|type|character}}{{code|whitespace|&nbsp;}}{{code|variable|c}}{{code|whitespace|&nbsp;}}{{code|keyword|in}}{{code|whitespace|&nbsp;}}{{code|variable|Berry Punch}}{{code|whitespace|&nbsp;}}{{code|punctuation|.}}{{code|punctuation|.}}{{code|punctuation|.}}{{code|whitespace|<BR/>}}{{code|keyword|I said}}{{code|whitespace|&nbsp;}}{{code|variable|c}}{{code|punctuation|.}}{{code|whitespace|<BR/>}}{{code|keyword|That's what I did}}{{code|punctuation|!}}}}
+
{{codeblock|{{code|keyword|Did you know that}}{{code|whitespace|&nbsp;}}{{code|variable|Berry Punch's favorite thing to say}}{{code|whitespace|&nbsp;}}{{code|keyword|is}}{{code|whitespace|&nbsp;}}{{code|type|the word}}{{code|whitespace|&nbsp;}}{{code|literal|&ldquo;Cheerwine&rdquo;}}{{code|punctuation|?}}{{code|whitespace|<BR/>}}{{code|keyword|For every}}{{code|whitespace|&nbsp;}}{{code|type|character}}{{code|whitespace|&nbsp;}}{{code|variable|c}}{{code|whitespace|&nbsp;}}{{code|keyword|in}}{{code|whitespace|&nbsp;}}{{code|variable|Berry Punch's favorite thing to say}}{{code|whitespace|&nbsp;}}{{code|punctuation|.}}{{code|punctuation|.}}{{code|punctuation|.}}{{code|whitespace|<BR/>}}{{code|keyword|I said}}{{code|whitespace|&nbsp;}}{{code|variable|c}}{{code|punctuation|.}}{{code|whitespace|<BR/>}}{{code|keyword|That's what I did}}{{code|punctuation|!}}}}
   
 
==== Java Equivalent ====
 
==== Java Equivalent ====
{{codeblock|<SOURCE LANG=java>char[] BerryPunch = new char[]{'C','h','e','e','r','w','i','n','e'};
+
{{codeblock|<SOURCE LANG=java>char[] Berry_Punchs_favorite_thing_to_say = new char[]{'C','h','e','e','r','w','i','n','e'};
for(char c : BerryPunch){;;
+
for(char c : Berry_Punchs_favorite_thing_to_say){;;
 
System.out.println(c);
 
System.out.println(c);
 
}</SOURCE>}}
 
}</SOURCE>}}

Latest revision as of 17:14, October 29, 2014

Syntax Edit

Counting Edit

Iterating Edit

Examples Edit

Add all the numbers from 1 to 100 Edit

Did you know that Spike likes the number 0?
For every number x from 1 to 100...
Spike now likes Spike plus x.
That's what I did!

Java Equivalent Edit

double Spike = 0;
for(double x = 1; x < 100; x++){;;
Spike = Spike + x;
}

Iterate through an array Edit

Did you know that Berry Punch's favorite thing to say is the word “Cheerwine”?
For every character c in Berry Punch's favorite thing to say ...
I said c.
That's what I did!

Java Equivalent Edit

char[] Berry_Punchs_favorite_thing_to_say = new char[]{'C','h','e','e','r','w','i','n','e'};
for(char c : Berry_Punchs_favorite_thing_to_say){;;
System.out.println(c);
}


Icon Info
This article is a stub. You can help FiM++ Wiki by expanding it.

Around Wikia's network

Random Wiki