I think we should be able to add multiple conditio...
# language-proposals
y
I think we should be able to add multiple conditions with the
else
block too. I once faced a situation where a choice and fallback led to the same action. So I thought this might be something nice to have. Something like this
Copy code
fun main():Unit{
    var a = 5
    when(a){
        1,2-> print("Case 1")
        5,else -> print("Fallback")
    }	
}
I don't know if this has been discussed before so I thought I should ask about the suggestion here.
🤔 2
âž• 3
d
Why just don't remove
5
option?
Copy code
fun main():Unit{
    var a = 5
    when(a) {
        1, 2 -> print("Case 1")
        else -> print("Fallback")
    }	
}
y
@dmitriy.novozhilov Yes that works 😅 But I thought adding an option to do it like this might be good for readability and let a person working on this code in future to handle this case differently. Thinkng more about it, I guess this too can be done with comments 😂. Nvm this suggestion is stupid
🤣 3