Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Foundations Ruby Standard Library Observable

Wrong number of arguments error

Getting error, it looks like it's occuring on line for "AccountObserver.new" saying the wrong number of arguments (1 for 0). Feel like I'm doing the exact same thing as Jason in the video.

Here is code:

require 'observer'

class BankAccount include Observable

def initialize(name)
    @name = name
    @transactions = []
end

def deposit(amount)
    changed
    notify_observers(Time.now, 'deposit', amount)
    @transactions.push(amount)
end

def withdraw(amount)
    changed
    notify_observers(Time.now, 'withdraw', amount)
    @transactions.push(-amount)
end

end

class AccountObserver def initalize(account) @account = account @account.add_observer(self) end

def update(time, kind, amount)
    puts "[#{time} (#{kind})]: #{amount}"
end

end

account = BankAccount.new("Michael") AccountObserver.new(account)

account.deposit(100) account.withdraw(50) account.withdraw(25)