Check if a constant is already defined

后端 未结 3 1898
故里飘歌
故里飘歌 2020-12-09 00:45

This is a simple one, I hope. How do I check, in the following example, if a constant is already defined?

#this works
var = var||1
puts var
var = var||2
put         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-09 01:02

    CONST ||= :default_value
    

    the above works for me on ruby 1.9.3 but fails on 1.8... well 1.8 is ancient now.

提交回复
热议问题