in reply to overloading '0+'
The call to int is one call to truncate and then the assignment is the other.my $int = int($soldier1);
If you don't have bool overloaded and 0+ is overloaded then, 0+ will be used in a boolean context, which is why truncate is being called in this code;
$soldier ? 1: 0;
See overload for the all the gory details. (perldoc overload) The sections titled "Boolean, string and numeric conversion" and "Transcendental functions" answer your questions.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: overloading '0+'
by ikegami (Patriarch) on Sep 02, 2007 at 22:12 UTC | |
by bruceb3 (Pilgrim) on Sep 03, 2007 at 05:12 UTC |