class Song def initialize(name,artist,duration) @name = name @artist = artist @duration = duration end def to_s "Song : #{@name}--#{@artist} (#{@duration})" end end class SongList def initialize @songs = Array.new end def append(aSong) @songs.push(aSong) ...
2006-09-25

Ruby學習系列----疑問(1)

关键字: () 括號
def sayGoodnight(name) #result = "Goodnight #{name}" result = "Goodnight, " + name return result end puts (sayGoodnight ("john-bo")) Goodnight, john-bo 執行成功 puts sayGoodnight ("john-bo") Goodnight, john-bo warning: don't put space before argument parentheses puts sayGoodnight "john-bo ...
毛冬
搜索本博客
我的相册
5e524b83-3650-4303-bb16-d29f9fb9b805-thumb
白水寨..亲瀑台
共 1 张
存档
最新评论
评论排行榜