From: Mark Slagell Date: 2001-03-24T01:50:34+09:00 Subject: [ruby-talk:13147] Re: How would Ruby say this? Lyle Johnson: > >... > initial = 42.0 > status, result = getValue(initial, "What it is?") > if status > puts "The user responds: #{result}" > else > puts "The user cancelled without responding" > end > > begin > initial = 42.0 > result = getValue(initial, "What it is?") > puts "The user responds: #{result}" > rescue CancelError > puts "The user cancelled without responding" > end > ... Dave Thomas: > ... > A third option would be to return 'nil' on no input (as presumably nil > can never be returned). Then you can write > > if res = getValue("What's the frequency..") > process ... > else > no input > end There are times when returning multiple values in an array makes sense, but in this case the values are both really concerned with the same input, so yes it seems awkward. Either of the other approaches would seem pretty reasonable. -- Mark