Solidity Error ,begginer lesson3

Hello Fillip

I am just in the lesson number 3, here when we setNumber (deploy) and you get 10.0 to replace the number in get Number you suppose to recieve 10 (instead of 1 " the original numer") in my contract dont get the new number and show me an error , i am using the same version that you , i dont understant what is the mistake here someboby could help me ?

thanks in advance

Hey @ElyRamos,

The error is thrown because you’ve used a full stop (.) instead of a comma (,) to separate your 2 input arguments when you call setNumber. Solidity is reading this as a single string "15.0" and not as 2 numbers (you also can’t use decimals for the integer data types).
Using the comma instead will create both of the necessary input arguments:

15, 0      // newNumber, index

The new number 15 will now replace the number 1 at index 0.

That should sort it, but just let us know if you have any more questions.


thanks for your answer i tried this already but still doesn´t work , could you please be so kind and check it .
my code



pragma solidity 0.5.12;

contract HelloWorld{

string public message = "Hello World";

uint[] public numbers = [1, 20, 45];

function getMessage() public view returns(string memory){
    return message;
function setMessage(string memory newMessage) public {
  message = newMessage;

function getNumber(uint index) public view returns(uint){
    return numbers[index];

function setNumber(uint newNumber, uint index) public {
  numbers[index] = newNumber;

function addNumber(uint newNumber) public {

} `

Hi @ElyRamos,

You’re calling setMessage with two integer arguments (15, 0), but that function requires a single string argument. That’s why it’s throwing an error, and if you look carefully at the actual error message, you’ll see that that’s what it’s telling you.

You should be calling setNumber with  15, 0 . Then it should work :slight_smile:

yes , you are right my mistake . thanks !! :rofl:

1 Like