String memory name, uint age

Why is that we apply memory in a string, but not in a uint?

function createPerson(string memory name, string memory surname, uint age, uint height) public {

Tks

Hi @ruisousa

Explicit data location for all variables of struct, array, mapping is now mandatory, it improves the performance of your code.
Prior to version 0.5.0 the data location could be omitted, and would default to different locations depending on the kind of variable, function type, etc., but all complex types must now give an explicit data location.

String and Bytes are consider as special arrays in solidity, both of these are dynamic array types, which means that they can store data of an arbitrary size. You don’t need to use memory for an uint because it’s a simple type you will need the same amount of space to store a uint equal to 1 or 1000.

1 Like