Lesson 7- Hashes and Symbols


#1

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


#2

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).

#3

hi, this is the link:
https://www.codecademy.com/courses/ruby-beginner-en-Qn7Qw/1/2?curriculum_id=5059f8619189a5000201fbcb#
the code:
my_first_symbol=hash.new
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


#4

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

#5

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


#6

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