From: "David A. Black" Date: 2004-09-28T10:58:59+09:00 Subject: Re: {newb} Each statements Hi -- On Tue, 28 Sep 2004, Bill Guindon wrote: > On Tue, 28 Sep 2004 09:33:16 +0900, James Edward Gray II > wrote: > > > ndata = ndata.split(//).map{ |c| ((c[0]-97)+rand(10))%26 }.join > > That started to look a bit too perl like for me, so I decided to > compare the 'each_byte' and the 'split' approaches. Granted, it's a > simple comparison, but seems each_byte is a bit faster, and looks > easier to read (at least to me). > > btw, suggestions on simple benchmarking welcome. > > Here's my simple comparison script: > ###################################### > data = "some really silly string of text which will be encrypted soon" > > ###################################### > def encrypt_byte(data) > ndata = '' > a = data.size-1 I keep wondering what this 'a' is (I think it was in the original, also unused). Here's another technique you could add to the collection: "abc".split(//).inject("") {|str,c| str << (((c[0]-96) + rand(10)) % 26) + 97 } David -- David A. Black dblack@wobblini.net