Skip to content

Day of week

Go switch + default

Same task in: C++Rust

Flowchart (ISO 5807)

YesNoYesNoStartInput dd = 1Return «Пн»Endd = 2Return «Вт»EndReturn «?»EndFigure 1 — day

Source code

Go
func day(d int) string {
    switch d {
    case 1:
        return "Пн"
    case 2:
        return "Вт"
    default:
        return "?"
    }
}

The editor opens with this code — change it and the chart redraws.

Language
Go
Constructs
switch + default
Topic
Switch / case
Formats
Word, Visio, draw.io, PDF, SVG

Related examples