Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Ruby Objects and Classes Build a Bank Account Class Adding Transactions

why is the ":" sign at the end rather the begining of a symbol> isnt the right syntax :symbol rather than symbol:

when pushing hash into the array

class BankAccount
  attr_reader :name

  def initialize(name)
    @name = name
    @transactions = []
def add_transaction(description, amount)
    @transactions.push(:description description, :amount amount)

3 Answers

William Li
William Li
Courses Plus Student 26,865 Points

In Ruby's Hash literal.

{description: description, amount: amount}
# is just a shorthand of writing the following line
{:description => description, :amount => amount}

the narattor skipped that one,,,{!!!}

William Li
William Li
Courses Plus Student 26,865 Points

Really? Jason did?

But anyway, yeah, since when writing Ruby code, you'll write a lot of Hash, so Ruby just give you a shorthand, more concise way of writing it.

ive done all the hash tutorial, and tis syntax never appears. Jason simply used it without explaing this secret trick...:\