From: Paul Roche Date: 2010-10-06T03:59:39+09:00 Subject: Calling a method with an instance Hi. I'm playing around with creating methods and then creating an instance that calls the instance. Here's my code..... class Discount attr_accessor :amount, :discount def initialize(am, dis) @amount = am @discount = dis end def self.discount_amount(amt, disc) newamount = amt - disc end end dis1 = Discount.new(100, 20) dis1.discount_amount(amount, discount) The error I get is...... discount.rb:25:in `
': undefined local variable or method `amount' for main :Object (NameError) What is the best way to call a method with an instance? Thanks -- Posted via http://www.ruby-forum.com/.