Comment

Comment by neonsunset

This looks incredibly clunky and counter-intuitive.

Compare that to yield return, .Select and .Where methods in C#, or Filter and Map in many popular languages - it's not a good look.

Or when writing manually, compare it to

    static IEnumerable<T> Filter<T>(
        IEnumerable<T> source, Func<T, bool> predicate)
    {
        foreach (var item in source)
        {
            if (predicate(item))
                yield return item;
        }
    }
Could also compare to how easy it is to use for extremely common patterns in general purpose code:

    var numbers = Enumerable.Range(0, 10);
    var even = numbers.Where(n => n % 2 is 0);
    var strings = even.Select(n => n.ToString());
parent neonsunset 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton