From: Alan Burch Date: 2006-03-11T10:32:37+09:00 Subject: Re: Help me understand why the Ruby block is slower than wit Mark Devlin wrote: > > Solely for my own amusement, since I'm still trying teach myself Ruby... > > File.open("./words").read.split.collect! {|x| x if x.length == 10 && > x.split(//).uniq! == nil}.compact!.each {|x| puts x } Mark: Thanks for doing this way. I had thought about trying to read it in and split it up, but didn't know how to do it as I've only read a bit of the pikaxe book. On my two processor G5 with 4 gb of memory, your version is about 30% slower than the fastest method above. 18.69 vs 12.52 seconds. I intend to look a bit closer at your code and see if I can see another way to speed it up. Gary: Thanks for your input also. I saw the redundancy when William James gave me input, but really don't fully understand arrays vs strings in Ruby yet and also the differences in print vs puts and other types of output. I'll read through pikaxe a bit more right now. Others: Any input as to why it runs slower inside the file block? Have I overlooked something simple? -- Posted via http://www.ruby-forum.com/.