C# says you can, but should you?
2 likes 6 replies
Replies
Ben · Nov 24
Switch expressions and more-so ternaries inside string interpolation always make me feel weird. Weird enough to allocate vars above them. Especially if throwing an exception is involved.
Martin Stühmer · Nov 27
That is ridiculous. Don't get me wrong, I really like the “switch expressions” language feature, but the example shown goes a bit too far for me. It goes against everything I care about in terms of readability and maintainability.
Adam Storr · Nov 24
Not sure how I feel about this. It took too long to work out what it was doing. A separate var would aid with readability and hence maintainability imho
Jeppe Roi Kristensen · Nov 24
Depends. Do you hate the people who are going to read it? 😊
Luciano · Nov 26
Definitely
@mdykun-developer.bsky.social · Nov 25
I wouldn't due to the fact that the asset types are open to expansion. I also think its better to split into Single responsibility between URL creation and determining asset types.