Is it possible to have a getter for a const?

前端 未结 4 1956
忘掉有多难
忘掉有多难 2020-12-19 06:16

Just curious, is there a way to have a getter for a constant variable? I have a sort of internal version number to ensure that two versions of a library are still speaking t

4条回答
  •  自闭症患者
    2020-12-19 07:12

    Constants cannot be reassigned, hence why they are called constant therefore just make protocol_version public

    private const Int16 protocol_version = 1;
    

提交回复
热议问题