From: "Ara.T.Howard" Date: 2005-09-15T01:25:08+09:00 Subject: Re: Ternary operator request On Thu, 15 Sep 2005, Robert Mannl wrote: > Hi! > > I'm more or less an amateur programmer, but I have fallen in love with Ruby. > > I have an improvement idea for Ruby - I don't know if this is the best place > to post this, but I thought it might spark some discussion about whether > adding this "feature" would be healthy for the language or not. > > Let's suppose we have a method called: "some_method?". Why not allow writing > ternary operator expressions like this: > > some_method? a : b > > instead of > > some_method? ? a : b though this only works with the attribute type methods provided by traits: harp:~ > cat a.rb require 'traits' trait 'foo' => true puts( foo ? 'foo' : 'not foo' ) puts( foo? ? 'foo' : 'not foo' ) foo false puts( foo ? 'foo' : 'not foo' ) puts( foo? ? 'foo' : 'not foo' ) harp:~ > ruby a.rb foo foo not foo not foo cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | Your life dwells amoung the causes of death | Like a lamp standing in a strong breeze. --Nagarjuna ===============================================================================