Loops/Foreach: Difference between revisions

Replace println() with print(); replace output "syntaxhighlight" tag with "pre" tag
(Added EasyLang implementation)
(Replace println() with print(); replace output "syntaxhighlight" tag with "pre" tag)
Line 1,096:
{
val vals = [10, 20, 30, 40];
console.printlnprint("Array of values:");
Loop: for (val val : vals)
{
console.printlnprint($" value #{Loop.count + 1}: {val}");
}
 
Map<String, Int> pairs = ["x"=42, "y"=69];
console.printlnprint("\nKeys and values:");
for ((String key, Int val) : pairs)
{
console.printlnprint($" {key}={val}");
}
console.printlnprint("\nJust the keys:");
Loop: for (String key : pairs)
{
console.printlnprint($" key #{Loop.count + 1}: {key}");
}
 
console.printlnprint("\nValues from a range:");
for (Int n : 1..5)
{
console.printlnprint($" {n}");
}
}
Line 1,123:
</syntaxhighlight>
 
{{out}}
Output:
<pre>
<syntaxhighlight>
Array of values:
value #1: 10
Line 1,145:
4
5
</pre>
</syntaxhighlight>
 
=={{header|Efene}}==
162

edits