IssueRaiser

Match/switch expression

### Description I would like to request a match/switch statement feature for Typst. This would allow me to write conditional expressions that match a value against a set of patterns and execute different code blocks accordingly. ### Use Case take Rust for example: ``` match x { x if x < 2 => println!("x is less than 2"), x if x < 4 => println!("x is less than 4"), x if x < 6 => println!("x is less than 6"), x if x < 8 => println!("x is less than 8"), _ => println!("x is greater than or equal to 8"), } ``` it's better than writing a long if-else-if chain

Posted by 8LWXpg on May 24, 2023, 2:36 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments

github (Other)

Match/switch expression

8LWXpgMay 24, 2023, 2:36 PM

### Description I would like to request a match/switch statement feature for Typst. This would allow me to write conditional expressions that match a value against a set of patterns and execute different code blocks accordingly. ### Use Case take Rust for example: ``` match x { x if x < 2 => println!("x is less than 2"), x if x < 4 => println!("x is less than 4"), x if x < 6 => println!("x is less than 6"), x if x < 8 => println!("x is less than 8"), _ => println!("x is greater than or equal to 8"), } ``` it's better than writing a long if-else-if chain

Comments (0)

No comments yet. Start the discussion.

Comment on this issue