[IronPython] Default-valued arguments to C# functions

Jeff Hardy jdhardy at gmail.com
Tue Apr 27 00:52:33 CEST 2010

On Mon, Apr 26, 2010 at 2:41 PM, Dino Viehland <dinov at microsoft.com> wrote:
> Jeff wrote:
>> Interestingly, using DefaultValue worked for anything that wasn't an
>> object - `[Optional][DefaultValue(-1)]int index` worked just fine.
> I think you should have been getting a value of 0 when the parameter
> wasn't being provided in this case.  When something is optional but
> not typed to object we need to pass default(typeof(T)) instead of passing
> Missing.Value.

Go figure - I had a test for `index > 0`, instead of `index >= 0`... :).

The other one I had was for `[DefaultValue(0.0)]double timeout`, which
now makes sense.

- Jeff

More information about the Ironpython-users mailing list