vlang / rfcs

RFCs for changes to V

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cond simplifying and readablying if / else if /else

igotfr opened this issue · comments

// if / else if /else
if false { println('if') }
else if  true { println('else if') }
else { println('else') }

// cond equivalent
cond {
  false { println('if') }
  true { println('else if') }
  else { println('else') }
}
  
// with inline operator
// https://github.com/vlang/rfcs/issues/11
// https://github.com/vlang/v/issues/11345
cond =>
  false => println('if')
  true => println('else if')
  else => println('else')