5 ms·
Any other .NET folks out there that have accidentally misused the any() builtin when doing something in Python? About 2-3 times (with gaps of a year or so) I ha
by smcl 5y ago
Any other .NET folks out there that have accidentally misused the any() builtin when doing something in Python? About 2-3 times (with gaps of a year or so) I have accidentally used Python's any(some_collection) ("is there any element of some_collection that is truthy") where in .NET I would use someCollection.Any() ("is someCollection non-empty").
- clappski 5y agoWouldn't `Count` ( https://docs.microsoft.com/en-us/dotnet/api/system.collections.icollection.count?view=net-6.0#system-collections-icollection-count https://docs.microsoft.com/en-us/dotnet/api/system.collectio... ) be the preferred way to check if a collection has values? `someCollection.Any()` is the same as Python's `any`
- smcl 5y agoI didn't mean specifically ICollection, maybe I just used the wrong word (probably "enumerable" or "sequence" is better?). But I was referring to this method: https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.any?view=net-6.0 https://docs.microsoft.com/en-us/dotnet/api/system.linq.enum... > Determines whether any element of a sequence exists or satisfies a condition.