From: matt@... (matt neuburg) Date: 2009-01-28T09:47:49+09:00 Subject: Re: how can I switch over an array ? Tsunami Script wrote: > I have the following code snippet : > > def call(char,value) > case char > when " ","#","!","@","$","%","^","&","*","(",")","{","}"," > [","]","\'","\"","<",">",",",".","?",";","\n","\r" > @map[char].call(value) > when "digit" > @map[char].call(value) > when "char" > @map[char].call(value) > else > puts "don't know what to do with #{char} and #{value}" > end > end > > can the first when be written in a simpler way ? In days gone by, you might have written this sort of thing: when *" #!@$%".split("") -- extend string as desired But I don't know if that will work any more (Ruby 1.9)...? m. -- matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ Leopard - http://www.takecontrolbooks.com/leopard-customizing.html AppleScript - http://www.amazon.com/gp/product/0596102119 Read TidBITS! It's free and smart. http://www.tidbits.com