From: David Tillman Date: 2001-08-08T02:16:30+09:00 Subject: [ruby-talk:19299] Re: Speaking of the ternary operator.... >>>>> David Alan Black writes: > I seem to remember at one point someone saying that the ternary > operator might be vanishing from Ruby at some point. It may > have been over on irc, or in my fevered imagination. I'm not > sure. > Personally I wouldn't miss it, though that's neither here nor > there. I'm just curious about it. > David > -- David Alan Black home: dblack@candle.superlink.net work: > blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav It isn't very pretty. However; I do use it quite a bit to save many lines of if/then/else/end: @border = args[1].include?(H_border) ? args[1][H_border] : 0 @align = args[1].include?(H_align) ? args[1][H_align] : false @spacing = args[1].include?(H_spacing) ? args[1][H_spacing] : false @padding = args[1].include?(H_padding) ? args[1][H_padding] : false @width = args[1].include?(H_width) ? args[1][H_width] : false @bgcolor = args[1].include?(H_bgcolor) ? args[1][H_bgcolor] : false @bcolor = args[1].include?(H_bcolor) ? args[1][H_bcolor] : false @bclight = args[1].include?(H_bclight) ? args[1][H_bclight] : false @bcdark = args[1].include?(H_bcdark) ? args[1][H_bcdark] : false @center = args[1].include?(H_center) ? args[1][H_center] : false @format = args[1].include?(H_format) ? args[1][H_format] : [] It could be that there is a better way than how I am currently doing this and that I am falling into the trap of trying to duplicate code from one language to the paradigm over another - as this similiar to the form I wrote in Scheme: (let ((align (get-keyword :align args #f)) (valign (get-keyword :valign args #f)) (width (get-keyword :width args #f)) (height (get-keyword :height args #f)) (nowrap (get-keyword :nowrap args #f)) (colspan (get-keyword :colspan args #f)) (rowspan (get-keyword :rowspan args #f)) (bg-color (get-keyword :bg-color args #f)) (color (get-keyword :color args #f))) ...) The ternary is convenient because it is so alike to Scheme's (if ) -Dave (One of the other Daves) -- How absolute the knave is! We must speak by the card, or equivocation will undo us.