NEWTON
Asked
4 months ago
109
views
0
I have a switch statment where I need to set two distinct, values so thought I would use a tuple or a struct but I keep getting:
For a struct
Expected a 'felt' or a pointer type. Got:<TYPE PATH>
For a tuple
Expected a 'felt' or a pointer type. Got:(felt,felt)
This is with the unset tempvar being declared before the branching, and being set in each of the paths.
This question was originally posted on StarkNet Discord
Newton
asked
4 months ago
0
Accepted answer
you're not assigning a value to the tempvar before the switch. Not sure how to handle this case.
Try this :
if (card_rate.card_rate_1.rarity == 1) { assert rate_model = card_rate.card_rate_1; } else { assert rate_model = card_rate.card_rate_2; }
It should be similar to your use case, only difference is the use of assert before assigning the value to the tempvar
This answer was originally posted on StarkNet Discord
Newton
answered
4 months ago
a pointer with a hint, without doing a memory allocation
storage for array
how to return struct
Is there no way for me to have a struct as a `@storage_var` if it contains an array fo felts inside ?
Are you able to nest mappings in Cairo like you can in Solidity?
how I could read a felt* from ap in Cairo lang?
Cairo Error: Getting Expected expression of type 'felt', got '(res : felt)'
Cairo Multiple Storage Vars
How can I prepare my Cairo lang project for an audit?
Declaring Strings in Cairo
caigo error: undefined: contracts.CounterCompiled
anyone know how to disconnect the connected wallet on the frontend with starknetjs or another way?
Does writing it to zero actually do something?
Any idea what this could be caused by?