RE: [PHP-DEV] Feature request for min() and max()
| From: | Sterling Hughes | Date: | Mon, 20 Nov 2000 16:04:33 +0000 |
| Subject: | RE: [PHP-DEV] Feature request for min() and max() | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-38623@lists.php.net to get a copy of this message | ||
At 10:54 AM 11/20/2000 -0500, Colin Viebrock wrote:
I don't think that's a very good idea. If the user gives the min() function an invalid value, he should get an error. Well, my point I suppose is whether giving one value is really invalid. For instance, I am perhaps reading data from a log file, or from some other outside source where I have no idea going in how many values I am going to get. To then pass this data to min() or max(), without doing a if...else loop in *my* code (knowing that PHP will do the right thing) would be a lot nicer, IMHO. Yes, I could recode my scripts. But it seems intuitive to me to just do this.settype($var, "array"); $val = min($var); or: $val = min((array)$var); Not incredibly hard? And min() returns the minimum number of the different items in an *array* (or a passed set of values). I just think it enforces bad coding practices (like some Perl "features"). You should be sure of your variable types.
Anyway, the easiest way to this would simply be to change: <snip> Adding an if .. else is really kind-of unneccessary. Okay ... that's why I posted the code to the list first before committing.Its really just a style thing btw, still, I think that the logic should be separated a bit if you commit the patch. -Sterling