Hacker News new | ask | show | jobs
by frosas 5083 days ago
I agree keyword arguments are a better solution (but probably harder to implement).

Right now this is how I do this:

    function salute($user, array $options = null) {
        $options = (array) $options + array('shout' => false);
        $salutation = "Hi $user!";
        if ($options['shout']) $salutation = strtoupper($salutation);
        return $salutation;
    }
1 comments

It is significantly harder to implement, especially if you think about what happens with existing functions, especially internal ones.