Wu Language
  • Getting Started
  • Writing code
    • Declarations
    • Optionals
    • If and While
    • For
    • Switch
    • Functions
    • Structs
    • Module
    • Traits
Powered by GitBook
On this page
  1. Writing code

Switch

Switch expressions work basically like ifand can be used like the following:

a := compute_some_number()

switch a {
  | 0  => print("a is zero")
  | 10 => print("a is ten")
  | _  => print("something else")
}

And can be used as expressions:

foo: str = switch 10 {
  | 10 => "foo"
}

Very nice.

PreviousForNextFunctions

Last updated 5 years ago