Skip to content

How do you use math.add in a factory 'add' function? #3028

Answered by dvd101x
christianpetty asked this question in Q&A
Discussion options

You must be logged in to vote

You can use math.add inside createAddDim, but I think the conflict is the name you are using is causing a circular reference as the name of the created function is the name of one of the dependencias.

Could you try a different name and test if addDim works as expected?

export const createAddDim = factory('addDim', ['typed', 'Dim', 'add'], ({ typed, Dim, add }) => {
    return typed('addDim', {
        'Dim, Dim': function (a, b) {
            return new Dim(add(a.nominal, b.nominal), add(a.tolerance, b.tolerance))
        }
    })
})

Replies: 3 comments 23 replies

Comment options

dvd101x
Sep 13, 2023
Collaborator Sponsor

You must be logged in to vote
13 replies
@christianpetty
Comment options

@dvd101x
Comment options

dvd101x Sep 13, 2023
Collaborator Sponsor

@christianpetty
Comment options

@dvd101x
Comment options

dvd101x Sep 13, 2023
Collaborator Sponsor

Answer selected by christianpetty
@christianpetty
Comment options

@christianpetty
Comment options

@dvd101x
Comment options

dvd101x Sep 13, 2023
Collaborator Sponsor

@christianpetty
Comment options

Comment options

You must be logged in to vote
8 replies
@christianpetty
Comment options

@josdejong
Comment options

@christianpetty
Comment options

@christianpetty
Comment options

@josdejong
Comment options

Comment options

You must be logged in to vote
2 replies
@dvd101x
Comment options

dvd101x Sep 13, 2023
Collaborator Sponsor

@christianpetty
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants