オブジェクト指向は愚かな考え。この世は計算式 ★3©2ch.net (952レス)
上下前次1-新
抽出解除 レス栞
629(1): デフォルトの名無しさん [sage] 2016/08/04(木) 14:41:37.79 ID:gwNa+xfa(2/5) AAS
>>628あ、デコレータパターンの実装だったんだ。
同じ感じでこれ実装できる?
class Log
def output(s)
puts s
end
end
class TimeStampLog
def initialize(log)
@log = log
end
def output(s)
@log.output "#{Time.now} #{s}"
end
end
class PidLog
def initialize(log)
@log = log
@pid = Process.pid
end
def output(s)
@log.output "[#{@pid}] #{s}"
end
end
631(1): デフォルトの名無しさん [sage] 2016/08/04(木) 16:18:58.29 ID:0aO0sFCL(8/13) AAS
>>629
これでいい?
外部リンク:ideone.com
上下前次1-新書関写板覧索設栞歴
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 1.423s*