News for hackers. Stuff that matters.
Re:Zig's Curious Multi-Sequence for Loops by pmontra on Monday February 27, 2023 @11:24AM (#34958271)
I don't know how common working with ranges is in Zig. Ruby would iterate on multiple ranges by converting them to arrays

  one = (1..3)
  seven = (7..10)
  (one.to_a + seven.to_a).each {|n| puts n}
I suppose that if it was common they would have added a + method to Range. Actually I think that's possible to implement it with a refinement on the Range class.

Yup, it works. First time I ever used refinements.

  module JoinRanges
    refine Range do
      def +(other)
        self.to_a + other.to_a
      end
    end
  end

  using JoinRanges
  one = (1..3)
  seven = (7..10)
  (one + seven).each {|n| puts n}
Re:Zig's Curious Multi-Sequence for Loops by kdmccormick on Monday February 27, 2023 @11:44AM (#34958592)
This is different. You are concatenating the arrays, whereas the article & discussion are about zipping arrays.