11 ms·
Really? Including the @1, @2, positional arguments? Why are you a big fan of them? Maybe I'm missing something that makes them great.
by omaranto 8y ago
Really? Including the @1, @2, positional arguments? Why are you a big fan of them? Maybe I'm missing something that makes them great.
- barrkel 8y agoI almost invariably use x for @1 in existing code; for manipulating hashes, I almost always use |k, v|. If I'm working with pairs, |x, y|. What's the big difference between x and @1? y and @2? It doesn't really feel that significant to me. I'm a bit meh on the feature. I'm suspicious of lambdas / blocks that take more than three parameters, and for three parameters I'm good with |x, y, z| or |a, b, c|. I do think that giving them meaningful names is usually obscures intent more than it clarifies; |k, v| for maps and |i| for loops self-document well enough.
- jimbokun 8y ago"for manipulating hashes, I almost always use |k, v|. If I'm working with pairs, |x, y|" Those are massive improvements over "@1 @2". You make the case yourself. Using "k, v" as a convention immediately signifies these are a key and its value. Using x, y indicate this is a pair (and x and y are of the same type, I assume?).
- dragonwriter 8y ago> What's the big difference between x and @1? No more stuttering in single-line blocks.