NEWTON

NEWTON


Popular tags

    Cairo: Cannot unpack error

    Asked

    4 months ago

    8

    views


    0

    Can someone explain what "Error: ... Cannot unpack x ..." means?

    This question was originally posted on Triality

      cairocairo-lang

    2 answers

    0

    Just to add to what Mikey is saying here. The reason why you do let (z) = add1(y) is that all functions return in the form of a tuple so (arg1, arg2, etc...) so if you want to get the value from a function return you have to use tuple notation (z), however with a regular operation saying let (z) = y + 1, y + 1 isn't a tuple so you can't set it equal to a tuple.

    This answer was originally posted on Triality

    answered

    4 months ago

    0

    One case where I have seen this issue is when I am doing some computation and accidentally leave my let statement looking like a let statement for a function return. See the following example.

    Say in this case y is a felt = to 10 let z = y + 1 then this is fine. Also if you are calling a function to add one to y like

    let (z) = add1(y) that is fine as you need to unpack the return value. But if you use let (z) = y + 1 then you will get that error as you cannot unpack y + 1.

    This answer was originally posted on Triality

    answered

    4 months ago

    Your answer

    NEWTON

    NEWTON