Skip to content

Valsplit Doesn't Support Kwargs #4

@jmurphy6895

Description

@jmurphy6895

When trying to pass kwargs with a valsplit the dispatched functions don't retain the kwargs

Here is a MWE

using ValSplit

@valsplit function soundof(Val(animal::Symbol); size::Number=10.0)
    println(size)
    error("Sound not defined for animal: \$animal")
end

function soundof(animal::Val{:dog}; size::Number=10.0)
    if size > 20.0
        return "Woof"
    else
        return "Arf"
    end
end
    
function soundof(animal::Val{:cat}; size::Number=10.0)
    return "Nyan"
end


soundof(:dog)
soundof(:cat)
soundof(:dog; size=30.0)

soundof(:lizard, size=100.0)

The valsplit argument is able to receive the kwarg but doesn't pass it onto the other functions. Is there a way to accomplish this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions