Lesson 7- Hashes and Symbols


can I gat some help on lesson 7? I c'ant pass not matter what I write. I dont get it.


We may be able to help, but will need the following...

  1. A link to the exercise;
  2. what code you have so far;
  3. any error message(s).


hi, this is the link:
the code:
new_hash = { :y := my_first_symbol}
i tried couple of thing before this right here.
the error massage:
(ruby):1: syntax error, unexpected ':', expecting tASSOC
new_hash = { :y := my_first_symbol}
thank you


For this lesson we are not creating a new hash, only assigning a symbol to a variable.

Let's examine that error message...

This means that Ruby is expecting,

y => 'some value'

With a symbol as the key...

:y => 'some value`

However this is hash syntax, and not applicable in this exercise.

Study the example in the lesson text...

my_symbol = :my_symbol

puts my_symbol.is_a? Symbol    # true


thank you, it seems i need to take a second look at this topic.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.