2

solidity 报错,如下所示!!!!!

 3 years ago
source link: https://learnblockchain.cn/question/1908
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
solidity 报错,如下所示!!!!!

solidity 报错,如下所示!!!!!

image.png

不明白这个为什么会一致报错
报错内容

dynamicString.sol:27:22: DeclarationError: Undeclared identifier. Did you mean "name", "name3" or "nmae2"? return bytes(name2).length; ^---^

pragma solidity ^0.4.26;

contract DynamicString{
    
    string name3 = "字节字节";
    string nmae2 = "#$%^&*%%%";
   
    string name = "eleven";  // 0x656c6576656e
    
    

    function getChineseName() view returns(bytes){
        return bytes(name3);
    }

    function getLength3() view returns(uint){
    //  return name.length;
    
        return bytes(name3).length;
            
    }
 

    function getLength2() view returns(uint){
    //  return name.length;
    
        return bytes(name2).length;
            
    }

    
    function getLength() view returns(uint){
    //  return name.length;
    
        return bytes(name).length;
            
    }
    
    
    function changeName() view returns(bytes1){
    //  return name[0];
    
        return bytes(name)[0];

    }
    
    
    function getName() view returns(bytes){
        return bytes(name);
    }
    
    
    function changeName4() {
    //  return name[0];
    
        bytes(name)[1] = "Q";

    }
    
    
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK