3 ms·
What is "long"?
by aaronbrethorst 2y ago
What is "long"?
- brabel 2y agoAre you really confused when people don't think 3 operations constitutes "long"? I would guess anyone with half a brain would agree 3 operations is not long, maybe 5 or 6 and you will have many people agreeing, and above that most.
- aquariusDue 2y agoHere's an abomination of my own design in Rust for example: for (index, node) in nodes .expect("Error: No blocks for the Body") .children() .expect("Error: blocks node has no children") .nodes() .iter() .enumerate() { let block = Block::new(node, index); self.blocks.push(block); }
- maleldil 2y agoWhy the for loop instead of mapping the enumerate iterator into Block::new and collect::Vec?
- aquariusDue 2y agoI lack a good answer other than it didn't occur to me, now I have some code to refactor. Thanks!
- maleldil 2y agoFWIW, I've had to write similar code when there's some complex "folding" operation. I use map/filter a lot, but fold/reduce/accumulate always seemed harder to understand than a for loop. I also prefer nested loops rather than nested iterators.
- dsego 2y agoI agree with the sentiment but I don't think the mocking insult was necessary as per the HN guidelines https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- deleted 2y ago[deleted]