摘要:
#overrideto_smethodclassThingdefset_name(aName)@name=aNameenddefget_namereturn@nameendendclassTreasuredefinitialize(aName,aDescription)@name=aName@description=aDescriptionenddefto_s#overridedefaultto_smethod"The#{@name}Treasureis#{@description}\n"endendthing1=Thing.newthing1.set_name(" 阅读全文
摘要:
#ClassDemoclassDogdefset_name(aName)@myname=aNameenddefget_namereturn@mynameenddeftalkputs"Woo!I'm"+get_nameendendclassCatdefset_name(aName)@myname=aNameenddefget_namereturn@mynameenddeftalkputs"Miao!I'm"+get_nameendend#CreateinstancesoftheDogandCatclassesdog1=Dog.newdog2 阅读全文