Number::Fraction

James Laver james.laver at gmail.com
Thu May 2 22:44:10 BST 2013


On 2 May 2013, at 18:50, "Th. J. van Hoesel" <th.j.v.hoesel at gmail.com> wrote:

> Back to your code, line 198:
> 
>  if (@_ >= 2)
> 
> Why not check for 
> 
>  if (@_ == 2)
> 
> ?
> 
> it should have only two arguments to construct a fraction from calling Number::Fraction->new(1, 2);
> 
> Why would you allow it to pass other arguments?

It looks like a combination of defensive programming and laziness. If you check for length of two, you have to handle both the case of too few args and too many args in addition to the case of two args. This is lazier and will it really harm it people pass more than 2 to silently ignore the extras?

James


More information about the london.pm mailing list