From: "Damián M. González" Date: 2012-09-27T01:02:06+09:00 Subject: Subclassing Date Ey guys, can't understand what's happening here: require 'date' class Dia < Date def initialize(ano, mes, dia, obj_mes) @mes = obj_mes super(ano, mes, dia) end end a = Dia.new => # #Was expecting an error, no arguments has been passed a = Dia.new(2012, 6, 21, "foo") => TypeError: no implicit conversion to float from string from (irb):31:in `new' from (irb):31 from C:/Ruby193/bin/irb:12:in `
' #Seems that the 4th argument is taked by...super too?? WTF a = Dia.new(2012, 5, 26) => # a = Dia.new(2012, 5, 26, Date::ITALY) => # #Obvious is taked by super...but why? I don't expect that We can see that new() doesn't matter if it is no receive parameters, or if it receive, it behave like make Date.new, but why? I'm re-defining the method initialize in Dia, it sholud(am I wrong?) take exactly 4 parameters and asign the last one to the instance variable @mes. Why is this happening? I've tried putting super in the first line of the definition but the same's returned. Thanks for your time. -- Posted via http://www.ruby-forum.com/.