Dynamic constant assignment

后端 未结 7 814
眼角桃花
眼角桃花 2020-11-28 20:31
class MyClass
  def mymethod
    MYCONSTANT = \"blah\"
  end
end

gives me the error:

SyntaxError: dynamic constant assignmen

7条回答
  •  无人及你
    2020-11-28 20:41

    Constants in ruby cannot be defined inside methods. See the notes at the bottom of this page, for example

提交回复
热议问题