20 lines
517 B
Plaintext
20 lines
517 B
Plaintext
//ww:run-exit 10
|
|
// Migrated from 700_e2e row 100.
|
|
package main;
|
|
import strings;
|
|
fn pick(r: (i32 | void), miss: i32) i32 = {
|
|
match (r) {
|
|
case let i: i32 => return i;
|
|
case void => return miss;
|
|
};
|
|
return 0;
|
|
};
|
|
fn main() i32 = {
|
|
let s: str = "hello, world";
|
|
let i1: i32 = pick(strings.byteindex(s, ','), -1);
|
|
let i2: i32 = pick(strings.byteindex(s, 'z'), -1);
|
|
let i3: i32 = pick(strings.byteindex(s, "world"), -1);
|
|
let i4: i32 = pick(strings.byteindex(s, "nope"), -1);
|
|
return i1 + i2 + i3 + i4;
|
|
};
|