I’m on a Macbook and I’m using Visual Studio for coding, I usually take the recommendations that Visual Studio gives me when I’m coding, such as shortcuts or expressions that makes me code less and more efficient… So I was making code and in a point I had to use a switch to give a variable a different value depending on other variable, so when I finished, the IDE recommended me to replace the switch statement with the switch expression to short the code, which it looks something like this:
var result = bank.Status switch
{
BankBranchStatus.Open => true,
BankBranchStatus.Closed => false,
BankBranchStatus.VIPCustomersOnly => isVip
};
However when I saved it, Unity complained like if it didn’t recognize the code, so I return it back to normal, but gives me the question: Is this expression new to C#? and if so, will Unity be compatible with that on later versions?