From: "Aaron D. Gifford" Date: 2010-03-08T00:26:28+09:00 Subject: Re: Base-64 encoding--Just for the fun of it! On Sat, Mar 6, 2010 at 4:31 PM, wrote: > (s.unpack("B*")[0]+'0'*((6-s.size*8%6)%6)).scan(/.{6}/).map{|e|c[e.to_i(2)]}*''+'='*((3-s.size%3)%3) I notice you could shave off 2 more characters by using the same ? character literal for the '0' and the '=' characters: (s.unpack("B*")[0]+?0*((6-s.size*8%6)%6)).scan(/.{6}/).map{|e|c[e.to_i(2)]}*''+?=*((3-s.size%3)%3) I hope you don't mind, but I added your version to my file at: http://www.aarongifford.com/base64.rb.txt And I stole your character literal and range expansion (splat) ideas to improve my longer algorithm a bit too. Thanks again for teaching me about Range expansion inside method calls. Aaron out.