From: Nicholas Paul Johnson Date: 2004-04-03T15:26:46+09:00 Subject: Re: Learning Ruby, was a C geek... :) On Sat, 3 Apr 2004, Gregory Millam wrote: > > > I've written it, and it works correctly when compared to my program > > written in C, but at its core is a large case-when-end statement. > > This is not `sexy.' I was wondering if there was a better way to do > > this in Ruby, or if I'm just missing the point. > ... > > Ruby caters to the second style rather well, adding in lambda blocks. > > ops = [] > ops[0x01] = lambda { /* incrememnt accum 1 */ |address| Cpu.accum += 1 } > Yeah, thats cool. While were on the subject, what is technically the difference between some block, such as { |n| 1+n }, and the corresponding lambda { |n| 1+n }, or more specifically, how does the interpreter treat them differently? Also, could I assign a lambda to a variable as I would in scheme to create a function? -- Nicholas Paul Johnson nickjohnsonSPAM^H^H^H^H@virginia.edu http://manjac.ath.cx/nick _ ( ) ascii ribbon campaign - against html mail X - against microsoft attachments / \ http://www.google.com/search?q=ascii+ribbon --