Control Flow
Conditionals
Imported from the upstream Vibescript examples at control_flow/conditionals.vibe and runnable in the browser today.
Source
control_flow/conditionals.vibe
# vibe: 0.2
def fundraising_badge(amount)
if amount >= 100000
"legend"
elsif amount >= 10000
"elite"
elsif amount >= 1000
"gold"
elsif amount >= 500
"silver"
else
"bronze"
end
end
def choose_label(status)
if status == "active"
"needs attention"
elsif status == "complete"
"done"
else
"unknown"
end
end
def run
{
legend: fundraising_badge(100000),
gold: fundraising_badge(5000),
bronze: fundraising_badge(100),
active: choose_label("active"),
complete: choose_label("complete"),
other: choose_label("pending")
}
end
Output
Press run to execute run from this example.