Robert said:
For me it doesn't work in the same file. It should always throw as Guy
pointed out already. I guess you might have tested something different
(maybe you forgot "< A" in one of the files).
Here's my "real" code (BlogData.rb):
<code>
class Timed
attr_reader :time
def initialize
@time = Time.new # <-- line 23
end
end
class Entry < Timed
attr_reader :title, :description
def initialize(titleS, descS)
super()
@title = titleS
@description = descS
@comments = Array.new
end
def to_s
"E : #{@title} -- #{@description} [#{@time}]"
end
end
class Comment < Timed
attr_reader :text
def initialize(commentS)
super()
@text = commentS
end
end
e = Entry.new('title1','desc1')
puts e
</code>
My shell:
E : title1 -- desc1 [Fri Jan 23 15:11:27 Westeuropäische Normalzeit 2004]
And here's another file in the directory (t.rb):
<code>
require 'BlogData'
e = Entry.new('title1','desc1')
puts e
</code>
My Shell (with 'puts e' in BlogData.rb deleled):
/BlogData.rb:23:in `initialize': wrong number of arguments(0 for 2)
(ArgumentError)
from ./BlogData.rb:23:in `new'
from ./BlogData.rb:23:in `initialize'
from ./BlogData.rb:32:in `initialize'
from t.rb:17:in `new'
from t.rb:17