3 ms·
My understanding, though, is that idiomatic Ruby inverts the control for iteration (array.each(|thing| do stuff)), which leads to slightly different ergonomics,
by apendleton 9y ago
My understanding, though, is that idiomatic Ruby inverts the control for iteration (array.each(|thing| do stuff)), which leads to slightly different ergonomics, whereas idiomatic Python is like what Rust is now; see http://journal.stuffwithstuff.com/2013/01/13/iteration-inside-and-out/ http://journal.stuffwithstuff.com/2013/01/13/iteration-insid... for a comparison. Interestingly, Rust used to have iteration styled after Ruby's, and explicitly switched in rust 0.7: https://www.reddit.com/r/programming/comments/1hl2qr/rust_07_released/ https://www.reddit.com/r/programming/comments/1hl2qr/rust_07...
I think the comparison here is also to Python because the specifics of the API, rather than just the patterns, are pretty obviously inspired specifically by Python (names of functions like zip, etc.), as opposed to other external-iterator languages like C#