From: Jack Dempsey Date: 2002-03-10T07:10:14+09:00 Subject: RE: Setting mutually inclusive vars if your variables are related as you've shown, as well as the variables coming in, you can use ranges and arrays--a range for your params and just set array[i] in a loop. Also, I forget the syntax, but if you don't want to use an array, you should be able to use dynamically named variables in a loop and set them accordingly jack > -----Original Message----- > From: ysantoso@thomases.com [mailto:ysantoso@thomases.com]On Behalf Of > Yohanes Santoso > Sent: Saturday, March 09, 2002 4:37 PM > To: ruby-talk ML > Subject: Setting mutually inclusive vars > > > 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. > >