fn foo() {
"bar"
}
compiles to this typescript:
function foo() {
return "bar";
}
fn test(in: Option<boolean>) {
let stuff = if let Some(v) = in {
v
} else {
"Hello"
};
stuff
}
compiles to this typescript:
function test(in: boolean | null) {
let stuff;
if (in != null) {
stuff = in;
} else {
stuff = "Hello";
}
return stuff;
}
or this typescript:
function test(in: boolean | null) {
let stuff = in != null ? in : "Hello";
return stuff;
}
fn matchStuff(in: Option<string>) {
match in {
Some(v) => console.log(v),
None => console.error("Hello")
}
}
compiles to this typescript:
function matchStuff(in: string | null) {
switch (in) {
case null:
console.error("Hello");
break;
default:
console.log(in);
}
}
how would this work?