Comment

Comment by dorianmariefr

This is not idiomatic ruby, you would do

    class Stuff
      attr_reader :list

      def initialize
        @list = [1, 2, 3, 4]
      end
    end
Then:

    Stuff.new.list.each { |item| ... }
    Stuff.new.list.map { |item| ... }
    Stuff.new.list.select { |item| ... }
And if you want top-level each/map/select methods, you could do

    delegate :each, :map, :select, to: :list

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton