オブジェクト指向は愚かな考え。この世は計算式 ★3©2ch.net (961レス)
前次1-
抽出解除 レス栞

628
(1): デフォルトの名無しさん [sage] 2016/08/04(木)14:13 ID:0aO0sFCL(7/13)
>>627
自分にはウィキペのデコレーターにあるJavaの例の要求仕様は満たしているように見えるけど。
具体的にはどこが不満?
629
(1): デフォルトの名無しさん [sage] 2016/08/04(木)14:41 ID:gwNa+xfa(2/5)
>>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
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.025s