V语言 Switch
fn main() { os := 'windows' print('V is running on ') switch os { case 'darwin': println('macOS.') case 'linux': println('Linux.') default: println(os) } // TODO: replace with match expressions }
switch语句是编写 if-else语句的较短方法。 它运行第一种情况,其值等于条件表达式。
与C语言不同的是,V语言中不需要为每个匹配的代码块都添加break语句。

