The switch statement follows this syntax:

switch expression {
	case value1: {
		doSomething()
	}
	case value2: {
		doSomethingElse()
	}
	default: {
		doSomethingMore()
	}
}

Unlike in many C-based languages, there is no need for a "break" statement at the end of the code blocks, as the blocks are cleanly terminated by the end of the block. The curly braces are mandatory.


Twitter Facebook LinkedIn Youtube Slideshare Github