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' } }