Skip to content

Conditionals

Conditionals execute different code depending on whether a condition is true or false. Junlang conditionals are written in a conversational style, as if talking to a person.

TIP

For how conditions are evaluated as true/false, see True and False.

Simple Condition (if)

If the condition is true, the statements inside the block are executed.

junlang
준서야 [condition] 맞냐?
  [statements]

Example

junlang
준서야 맞냐?
  오준서오

The condition (1) is true, so it outputs (1).

Either-Or (if-else)

If the condition is true, the first block is executed; if false, the second block.

junlang
준서야 [condition] 맞냐?
  [statements when true]
아니냐?
  [statements when false]

Example

junlang
준서야 오? 맞냐?
  오준서오
아니냐?
  오준서오오

The condition 오?(0) is false, so it outputs 오오(2).

Additional Conditions (if-elif)

When the first condition is false, another condition is checked.

junlang
준서야 [condition1] 맞냐?
  [when condition1 is true]
아니면 [condition2] 이건?
  [when condition2 is true]

아니면 ... 이건? can be chained multiple times.

junlang
준서야 [condition1] 맞냐?
  [when condition1 is true]
아니면 [condition2] 이건?
  [when condition2 is true]
아니면 [condition3] 이건?
  [when condition3 is true]

All Conditions + Fallback (if-elif-else)

By combining 아니면 ... 이건? with 아니냐?, you can add a block that executes when all conditions are false.

junlang
준서야 [condition1] 맞냐?
  [when condition1 is true]
아니면 [condition2] 이건?
  [when condition2 is true]
아니냐?
  [when all are false]

Keyword order matters

Within a conditional, 아니면 ... 이건? can appear multiple times, but 아니냐? (else) must always come last and only once.

Writing on a Single Line

Conditionals can also be compressed into a single line following the inline writing rules.

junlang
준서야 맞냐?
  오준서오
junlang
준서야 맞냐? 오준서오ㅋㅋ

The two code snippets above have exactly the same meaning.