newbie question: Can D do this?
chrono at mta-international.net
Wed Dec 21 00:36:18 PST 2011
In PHP frameworks often use $option arrays which are some kind of key
value pairs. they are merged with the default valuzes inside the function.
- you can pass an argument by name
- you only need to pass those who needed.
- hash arrays
it should be possible to create a similar method in d. but I really
don't like this solution in d. it feels bad and looks ugly.
'firstname' => 'John',
'country' => 'France',
'order' => 'asc'
function query($options = array())
// merge with defaults
$options = array_merge(array(
'deep' => true,
'order' => 'desc',
'type' => 'sql',
'backend' => 'mysql'
More information about the Digitalmars-d-learn