静的型付け言語の潜在開発生産性は今の100倍 ×4
■ このスレッドは過去ログ倉庫に格納されています
0497デフォルトの名無しさん
2013/11/12(火) 01:29:18.46class Integer
def sum(y); self + y.to_i; end
def to_i; self; end
def to_f; Convert.integer_to_float(self); end
end
class Float
class sum(y); self + y.to_f; end
def to_i; Convert.float_to_integer(self); end
def to_f; self; end
end
aFloat.sum aCat # ==> モジュール Convert でTypeErrorを検出
aDrink.sum aIceCream # ==> クラス Drink におけるsumの定義に従う
■ このスレッドは過去ログ倉庫に格納されています