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.
Agree it's weird, but if you're guaranteed to only need the result for that single string it might be alright.
I'm not fully sure how I feel about it yet as I haven't seen it in the wild that often 🤔
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.
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
I'm not sure I can answer that in a public setting! 😂
Honestly though, the syntax highlighting makes it look not very much different from doing it separately.
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.
I suppose that depends on many things. From a code standpoint obviously its functional of extremely low risk. However are you doing more file name, type mapping in the product if so maybe an abstraction around key FT functionality.