bitbonk

@bitbonk@mastodon.social

Can someone explain why collection expressions inside foreach do not work in

and 9 ? Why shouldn't this be possible? Why do I need to cast to IEnumerable<string> ?

February 27, 2025 at 6:09:17 PM

Because the collection expression doesn't have a type in your case, so it can't be assumed to implement an IEnumerator/IEnumerable interface. That would be my guess.

That's why the cast in the second case "fixes" the issue.

Elk Logo

Welcome to Elk!

Elk is a nimble Mastodon web client. You can login to your Mastodon account and use it to interact with the fediverse.

Expect some bugs and missing features here and there. Elk is Open Source and we're actively improving it as a community project. Join us and let's build it together!

If you'd like to report a bug, help us testing, give feedback, or contribute, reach out to us on GitHub and get involved.

To boost development, you can sponsor the Team through GitHub Sponsors. We hope you enjoy Elk!

Anthony FuPatakDaniel Roe三咲智子 Kevin DengJoaquín SánchezTAKAHASHI Shuuji

The Elk Team