syntax.switch_statement
Choice written with switch or when.
Area 3, Logic; not declinable; the next step is usually the agent's.
A choice between cases is a match, with arms pattern -> result: switch and when are match, case goes, and default or else is _.
type TicketStatus = Enum { open closed}type Rank = Int { min: 1}function rank(status: TicketStatus) -> Rank { return switch (status) { TicketStatus.open -> 1 TicketStatus.closed -> 2 }}
error Jadpo writes match, not switch
--> main.jadpo:11:12
|11 | return switch (status) { | ^^^^^^ write `match`
- reason
switchchooses between cases in JavaScript, Java, C#, Go and Swift, andwhenin Kotlin; Jadpo'smatchdoes, with one arm per line,pattern -> result, covering every case.- next
- Use
matchinstead ofswitch(agent) - rule
- syntax.
switch_ statement - help
- https://jadpo.
dev/docs/errors/syntax. switch_ statement
Markdown for agents: /docs/errors/syntax.switch_statement.md.Built from Jadpo main at aee2e8f.