On Mon, Aug 10, 2009 at 10:43 AM, Brian Candler<b.candler / pobox.com> wrote: > Robert Dober wrote: >> (1<<n).times.map{ | d | "%0{n}b" % d } > > Perhaps safer to avoid the interpolation in the format string, using '*' > to give the number of digits. > >>> "%0*b" % [8,123] > => "01111011" Well safer, you mean regarding to my typo, well spotted ;). This is a fascinating idiom I was not aware of. I too prefer it, thx for sharing. Cheers Robert > -- > Posted via http://www.ruby-forum.com/. > > -- module Kernel alias_method : :lambda end