Edgardo Hames ha scritto:
> On Fri, 5 Nov 2004 19:08:42 +0900, gabriele renzi
> <rff_rff / remove-yahoo.it> wrote:
> 
>>Edgardo Hames ha scritto:
>>
>>
>>>"KDialog is a wrapper class for KDE kdialog application. kdialog is a
>>>simple (easy to use) program which lets you build GUIs for your apps
>>>and scripts. The KDialog class tries to bring that simplicity into
>>>your Ruby programs."
>>>
>>
>>just a thing. It would be nice it KDialog::NO and KDialog::CANCEL had
>>false values (i.e false and nil)
>>
>>so that you could write
>>if Kdialog.new("Test").yesno('Do you like this class?)
>>  p 'thanks'
>>else
>>  p 'then go playing with curses'
>>end
>>
> 
> 
> Actually, I did think of that, but I didn't know what to do in the
> following scenario:
> 
> Kdialog.new("Test").yesnocancel('Save and Quit?)
>   Yes means save and quit
>   No  means !save and quit
>   Cancel means !quit
> 
> How can I differentiate between No and Cancel if they have the same values?

I'm not suggestint to have the same values :)
I'm suggesting to have false for No and nil for Cancel.
This way you could do:


res=Kdialog.new("Test").yesnocancel('Save and Quit?)
if res
  save and quit
else
   resume_main_loop if res.nil?
end
# the only other case where res != true is res==false