From: "Sebastjan H." Date: 2012-08-25T04:26:26+09:00 Subject: Re: learning by doing part 2 - tc game Once again, I turn to you for your wisdom:) Why this works: ----------------------------------------- class Depo attr_accessor :test def initialize(test) @test = test end def test() @test end end bla = Depo.new("blahdsd") def defin (bla) if defined? test puts "#{bla.test}" end end defin(bla) ------------------------------------------ And this doesn't: ------------------------------------------ def effect_output(card) if defined? attack puts "#{card.name.capitalize} hits with #{card.attack}." elsif defined? heal puts "#{card.name.capitalize} heals for #{card.heal}." end end ------------------------------------------ The card is a DRAGON class object with method attack defined. It has the attr_accessor as well as initialize method defined. I don't even get an error. Nothing gets putsed. If I use if defined? :attack then I get the message that attack is an undefined method for class HEAL. ??? -- Posted via http://www.ruby-forum.com/.