标签:def tle put str ali his info 静态方法 sel
class Game def initialize(id,title,price) @id=id @title=title @price=price end def showGame puts @id+" "+@title+","+@price._to_s end def self.toStr puts "I love this game." end end zelda=Game.new("zelda","sister",‘unlimit‘) zelda.showGame Game.toStr Game::toStr
执行结果
class Game def initialize(id,title,price) @id=id @title=title @price=price end def showGame puts @id+@title+@price.to_s end def self.toStr puts "I Love this game." end end class SteamGame<Game def SteamInf puts "i am a good man" end end SteamGame.toStr mygame=SteamGame.new("nobunage-taishi","sister",3000) mygame.showGame mygame.SteamInf
标签:def tle put str ali his info 静态方法 sel
原文地址:https://www.cnblogs.com/1521681359qqcom/p/12524381.html