Rob Biedenharn wrote:
> On Feb 15, 2010, at 9:47 PM, Marnen Laibow-Koser wrote:
>> Gui Djos wrote:
>>>  if a == 0
>>>    puts "Not a second degree equation.\n\n"
>>
>> Why the \n\n?
>>
>>>  if delta < 0
>>>    puts "Negative Delta.\n\n"
>>
>> Why the \n\n?
> 
> Marnen, that's probably because puts only adds a "\n" if it needs to
> so it takes "\n\n" to leave a blank line in the output.

Well, yeah.  That seemed like an odd place to put it, though.

> 
>>
>>>  end
>>>
>>>  return x_1,x_2
>>
>> You can't return multiple values; you'll have to wrap them in an array
>> (your assignment statement below will still work).
> 
> You can return multiple values just as you have it.  What gets
> returned is actually an array and will permit the kind of parallel
> assignment you expect.  (If you only have one value, it will get the
> array itself.)

That's good to know.  Gui, sorry for steering you wrong!  I never even 
thought to try doing a multiple return like this.

> 
>> Are you developing test-first?  If not, that's a bad practice.
> 
> Gui, I have to agree with Marnen on this one.  Particularly for this
> kind of stuff where it is very easy to define both good and bad results.

My point exactly.  Mathematical programming is one area where test-first 
development is particularly easy and powerful.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen / marnen.org
-- 
Posted via http://www.ruby-forum.com/.