0
function tokenURI(uint256 tokenId) public view virtual override returns (string memory){ require(_exists(tokenId),"ERC721Metadata: URI query for nonexistent token"); //if the block timestamp is divisible by 2 show the aURI if (block.timestamp % 2 == 0) { return bytes(aUri).length > 0 ? string(abi.encodePacked(aUri, tokenId.toString(), baseExtension)) : ""; } 

I am a little confused as to what the line of code in the return block means (what does the "?" signify, sorry for my noob question, I'm just dipping my feet into solidity.

 ? string(abi.encodePacked(aUri, tokenId.toString(), baseExtension)) : ""; 

1 Answer 1

1

That is a conditional if that works like this: (boolean_expression)? if true execute this side: if false execute this side.

Meaning in your case:

if (return bytes(aUri).length > 0) { return string(abi.encodePacked(aUri, tokenId.toString(), baseExtension)) } else { return ""; } 
1
  • 1
    Thanks Julissa...Understood! :) Commented Feb 25, 2022 at 10:21

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.