def info $myGlobal = "Hello" # 在类内部访问全局变量 puts "方法内部的输出 " + $myGlobal end class Test1 # 在类内部访问全局变量 puts $myGlobal end info class Test2 # 在类内部访问全局变量 puts "方法被调用之后的输出全局变量 " + $myGlobal end
2,764
社区成员
1,761
社区内容
加载中
试试用AI创作助手写篇文章吧