Why no default value for round or trunc on Point

No default value for round or trunc on Point?

On the class Point, the methods round & trunc do not have a default value for their first argument.
This is not the case on other classes.
Is this by design?

On AbstractFunction, SequenceableCollection & SimpleNumber the first argument for round and trunc has a default value (of 1).
So this: 1.49.trunc; works.
But Point(1.49, -9.87).trunc; throws an exception;

More examples:

These all work, and all give the same result: 1.0

  1.49.trunc(1);      // #1
{ 1.49 }.trunc.value; // #2
[ 1.49 ].trunc[0];    // #3
  1.49.trunc;         // #4

  1.49.round(1);      // #1
{ 1.49 }.round.value; // #2
[ 1.49 ].round[0];    // #3
  1.49.round;         // #4

Most of the following work, and give the same result: Point(1.0, -10.0).
Except #4 in each case throws an error:
ERROR: Message ‘asPoint’ not understood.

  Point(1.49, -9.87).trunc(1);      // #1
{ Point(1.49, -9.87) }.trunc.value; // #2
[ Point(1.49, -9.87) ].trunc[0];    // #3
  Point(1.49, -9.87).trunc;         // #4
// #4: ERROR: Message 'asPoint' not understood.

  Point(1.49, -9.87).round(1);      // #1
{ Point(1.49, -9.87) }.round.value; // #2
[ Point(1.49, -9.87) ].round[0];    // #3 (of 1)
  Point(1.49, -9.87).round;         // #4
// #4: ERROR: Message 'asPoint' not understood.
1 Like

Nope, feel free to put in a PR.

hjh

1 Like