# Default function arg values for abstracts

**URL:** <https://community.haxe.org/t/default-function-arg-values-for-abstracts/1703>\
**Category:** Haxe\
**Created:** [April 26, 2019, 4:41pm UTC](https://community.haxe.org/t/default-function-arg-values-for-abstracts/1703 "2019-04-26T16:41:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zagortenej](https://community.haxe.org/user_avatar/community.haxe.org/zagortenej/32/848_2.png) [@zagortenej](https://community.haxe.org/u/zagortenej)\
**Post date:** [April 26, 2019, 4:41pm UTC](https://community.haxe.org/t/default-function-arg-values-for-abstracts/1703/1 "2019-04-26T16:41:21Z")

</div>

I have abstract class declared like this:

```
abstract MyAbstractClass(Vector<Float>) from Vector<Float> to Vector<Float> {
....
    @:from
    public static function fromInt( value : Int ) : MyAbstractClass {
    ....
    }
....
}

```

This kind of code works (as intended):

```
var abc : MyAbstractClass = 12345;

```

but this kind of declaration doesn’t:

```
function aFunction( param : MyAbstractClass = 54321 ) {....}

```

with error being:

```
.... : Int should be MyAbstracClass

```

As one solution, I could have `MyAbstractClass` declared like this:

```
abstract MyAbstractClass(Int) from Int to Int { ... }

```

in which case I don’t get the error when declaring a function with default argument value. This is viable in my case but I would rather stick with `Vector<Float>`.

Is `@from` supposed to work with default value arguments or not? What am I missing here?

Is there some other way to tell Haxe to use implicit cast in case of default argument values when the value is not of the same type as argument and appropriate conversion method is provided?
