On Mon, 25 Nov 2002 15:32:38 +0900, Bulat Ziganshin wrote: > some suggestions for ruby: > > 1. list comprehension > { |x<-0...n| x*2 } > { |n, x<-0...n, y<-0..x| [x,y] } Why not do this another way? irb> (0...5).collect { |x| x * 2 } [0, 2, 4, 6, 8] The second one would be mildly harder: irb> (0...5).collect { |x| (0..x).collect { |y| [x, y] } } [[[0, 0]], [[1, 0], [1, 1]], [[2, 0], [2, 1], [2, 2]], [[3, 0], [3, 1], [3, 2], [3, 3]], [[4, 0], [4, 1], [4, 2], [4, 3], [4, 4]]] That is, if I understand your second one. Obviously, I'm using n = 5. > 2. default argument name to block/method > map {_*2} list # same as map {|x| x*2} list > map {_.lc} list # same as map {|x| x.lc} list > def x2 => _*2 # def x2(x); x*2; end I'm afraid that I don't see the point of these, except obfuscation. All you've done here is replace '|x| x' with '_', and that does nothing to help readability, IMO. -austin -- Austin Ziegler, austin / halostatue.ca on 2002.11.25 at 11.53.13