Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 2.67 KB

conditional-expression.md

File metadata and controls

68 lines (47 loc) · 2.67 KB

conditional

Open in playground

export const main = asl.deploy.asStateMachine(
  async (args: { name?: string }) => {
    const obj = { name: undefined };
    return obj.name ? obj.name : "jim";
  }
);

conditional with literal

Open in playground

export const main = asl.deploy.asStateMachine(async () => {
  return false ? "jim" : "james";
});

conditional within expression

Open in playground

export const main = asl.deploy.asStateMachine(
  async (args: { name?: string }) => {
    const obj = { name: "jim" };
    return "hello" + obj.name ? obj.name : "world";
  }
);

nested conditional

Open in playground

export const main = asl.deploy.asStateMachine(
  async (args: { name?: string }) => {
    const obj = { name: "jim" };
    return null ? "doesn't happen" : obj.name ?? "world";
  }
);

conditional within string format

Open in playground

export const main = asl.deploy.asStateMachine(
  async (args: { name?: string }) => {
    const obj = { name: "jim" };
    return `hello: ${obj ? obj.name : "jim"}`;
  }
);