Method and variable name is the same

后端 未结 4 408
难免孤独
难免孤独 2020-12-03 18:29

If both a method and a variable has the same name it will use the variable.

hello = \"hello from variable\"

def hello
  \"hello from method\"
end

puts hell         


        
4条回答
  •  半阙折子戏
    2020-12-03 19:10

    puts self.hello
    

    By the way, I agree with Henrik P. Hessel. This is a very horrible piece of code.

提交回复
热议问题