From: Bill Clagett Date: 2002-03-10T07:08:45+09:00 Subject: Re: Setting mutually inclusive vars I think I'd prefer separating out the mapping bit. Something like: mapping = [ ['a', 'somevar1'], ['b', 'somevar2'] #etc. ] mapping.each do |p, var| if param[p].set eval("@{v} = 1") end end bill "Yohanes Santoso" wrote in message news:<666A7356D67AD09E.5E1DF2DD91FE416B.68CDC7597CD42040@lp.airnews.net>... > Hi, > > I was working on a large cgi script. I had to set several variables > depending on what the user chose. That part ended up looking like > this: > > somevar1 = 1 if param["a"].set? > somevar2 = 1 if param["b"].set? > somevar3 = 1 if param["c"].set? > ... and so on .. (32 lines in total). > > 1) I was wondering if there are some better way to do this. > > 2) Which do you guys think is more aesthatically pleasing? > 32 lines of: if param["a"].set? then somevar=1 end > or 32 lines of: somevar=1 if param["a"].set? > > YS. >