From: Robert Klemme Date: 2006-05-08T21:27:14+09:00 Subject: Re: Language challenge 2006/5/8, C Erler : > Robert Klemme wrote: > > - remove explicit throw as you will get an exception from to_str > > anyway if it's not there > > I wanted the method to have a behavior consistent with others that don't > get the right type to take advantage of programmer debugging habits. > I'll have no problems if anyone changes it, though. > > > - use concat over += for efficiency > > - use case for discrimination > > I like both of these and have added them. I just learned about case > with comma separation yesterday, so this is an excellent opportunity to > use it. > > Thanks for the suggestions. You're welcome. I have another one: you have two calls to map! - you could do that in one go. result.map! do |value| # Rotate each byte by four bits. value = ((value << 4) | (value >> 4)) & 0b11111111 # Put the output in the correct format. case value when 0, 5, 36, 96, 124, 126 '/%%DCN%03d%%/' % value else value.chr end end Kind regards robert -- Have a look: http://www.flickr.com/photos/fussel-foto/