0
votes

When I try to call CustomerFactory function I get

ParserError: Expected identifier but got '('
    CustomerFactory(1,28);

I went over the documentation and I didn't see what I did wrong. Can someone advise?

pragma solidity ^0.7.0;

contract Manmade {

    struct Customer {
        uint customerID;
        string nick;
    }

    Customer[] public customers;

    function CustomerFactory(uint _customerID,string memory _nick)public{
        customers.push(Customer(_customerID,_nick));
    }

    CustomerFactory(1,"Peter");
}
1

1 Answers

1
votes

Your code CustomerFactory(1,"Peter"); is out of any function body which is not possible with solidity. Put this code into a function and it will work.