Search a list: Difference between revisions
Add Ecstasy example
m (→{{header|Wren}}: Minor tidy) |
(Add Ecstasy example) |
||
Line 1,489:
.
</syntaxhighlight>
=={{header|Ecstasy}}==
The <code>List</code> type has an <code>indexOf()</code> method, and the <code>Array</code> type is a <code>List</code>:
<syntaxhighlight lang="ecstasy">
module test {
@Inject Console console;
void run() {
String[] haystack = ["this", "needle", "is", "a", "test"];
if (Int pos := haystack.indexOf("needle")) {
console.print($"Found the needle at {pos=}");
} else {
console.print("No needle in the haystack");
}
}
}
</syntaxhighlight>
{{out}}
<pre>
x$ xec test
Found the needle at pos=1
</pre>
=={{header|Elena}}==
|