NEWTON
Asked
6 months ago
33
views
1
Hi, I'm trying to solve a Playground exercise on the Cairo website named "Conditionals". I don't know how to make OR operator in Cairo. I tried something like that:
func abs_eq(x: felt, y: felt) -> (bit: felt) {
if (x == -y) or (x == y) {
return (bit=1);
} else {
return (bit=0);
}
}
but it gives me an error
Error: code:12:18: Unexpected token Token('IDENTIFIER', 'or'). Expected: "{". if (x == -y) or (x == y) {
How can I solve it?
Hypobrai
asked
6 months ago
0
I think in this exercise they want you to know about if .. else statement. Try this:
func abs_eq(x: felt, y: felt) -> (bit: felt) {
if (x==y) {
return (bit=1);
}
if (x == -y) {
return (bit=1);
} else {
return (bit=0);
}
}
answered
6 months ago
How to make conditional expressions if..then..else in Cairo lang?
What is the difference between tempvar/let in Cairo Lang? How to use allow_locals and local?
Does Cairo Lang have any logic operators?
What does it mean to declare a 'local' variable inside a 'let'?
Cairo Lang / StarkNet: What are Revoked references? What is alloc_locals?
How to write "and" conditional logic in Cairo?
How to use get_fp_and_pc in Cairo Lang?
Has anyone had `get_caller_address` problems in devnet ?
If I want to use starkex do I have to deploy my custom starkex contracts?
ApeWorX: Using ape starknet accounts list
Are there situations in which we prefer declaring variables as `local` vs `tempvar`?
Why abi of warp compiled contract does not match original solidity abi?
What’s the difference between Account Abstraction (AA) and Externally Owned Accounts (EOA)?
Nethermind's warp error: JavaScript heap out of memory