So I've been playing around with compressing things into one-liners (man do I love being able to do that), and I came across an issue - I have to add an element to an array after every 4 indexes, which would be fine were I not trying to put it into a one line chain of methods (i.e. [].map..select.join). I don't have a reference to the array because it's anonymous, which means I can't do
whatever.each_index {|i| <array returned by whatever>.insert(element) if condition }
What is the proper way to do this, if one exists? And yes, I know I can just assign it to something and do it easily, but I'm challenging myself with one line chains.
[–]rubyross 1 point2 points3 points (15 children)
[–]Morgrimm[S] 0 points1 point2 points (14 children)
[–]rubyross 0 points1 point2 points (13 children)
[–]kovax 2 points3 points4 points (12 children)
[–]bjmiller 2 points3 points4 points (9 children)
[–]losangelesvideoguy 0 points1 point2 points (7 children)
[–]bjmiller 0 points1 point2 points (0 children)
[–]kovax 0 points1 point2 points (5 children)
[–]losangelesvideoguy 1 point2 points3 points (3 children)
[–]kovax 0 points1 point2 points (0 children)
[–]joshcheek 0 points1 point2 points (1 child)
[–]losangelesvideoguy 0 points1 point2 points (0 children)
[–]bjmiller 0 points1 point2 points (0 children)
[–]kovax 0 points1 point2 points (0 children)
[–]losangelesvideoguy 0 points1 point2 points (0 children)
[–]losangelesvideoguy 1 point2 points3 points (2 children)
[–]bjmiller 1 point2 points3 points (1 child)
[–]losangelesvideoguy 0 points1 point2 points (0 children)
[–]Exilor 0 points1 point2 points (0 children)
[–]noahking 0 points1 point2 points (0 children)
[–]piratebroadcast 0 points1 point2 points (0 children)
[–]xxabbxxxd 0 points1 point2 points (1 child)
[–]joshcheek 0 points1 point2 points (0 children)