Match


match语句是编写一系列if-else语句的较短语法,功能与switch类似。(switch已被移除)

os := 'windows'
print('V is running on ')
match os {
	'darwin' { println('macOS.') }
	'linux'  { println('Linux.') }
	else     { println(os) }
}
 
s := match number {
	1    { 'one' }
	2    { 'two' }
	else { 
		println('this works too')
		'many' 
	}
}