On Wed, Jun 18, 2008 at 9:39 AM, Phil Cooper-king [email protected]
wrote:
class Monster
attr_reader :monster
def initialize(monster) @monster = monster
end
def growl
puts ‘grrrrrrrr’
end
end
def speach
Verbal.new(self).growl
end
end
how can Verbal access the instance of Monster that created it?
I altered your code above, this should do what you’re looking for.
Basically, you just need to pass the instance of the Monster upon
creation
of the Verbal instance.
HTH,
Michael G.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.