# 14 Hashes and Symbols


#1




The code appears to work however I'm getting the message that primer is not listed and I cannot pass.

Here is the output:

primer
the_matrix
truman_show
skyfall
lion_king
{}


movie_ratings = {
  memento: 3,
  primer: 3.5,
  the_matrix: 5,
  truman_show: 4,
  red_dawn: 1.5,
  skyfall: 4,
  alex_cross: 2,
  uhf: 1,
  lion_king: 3.5
}
# Add your code below!

good_movies = movie_ratings.select do |m,r|
    if r > 3
        puts m
    end
end


#2

A select loop is quite intricate as such you don't need an if statement to print out hash values for example look at this code,

people = {
  Dave: 10,
  Scriptplayer: 20,
  person: 30,

}

people = movie_ratings.select { |x, y| y > 10 }

The code above will print out only scriptplayer and person because I have a condition that checks if y the value of the key is greater than 10. :slight_smile: You can use this same logic to structure your good_movies loop. :slight_smile:


#3

select has its own built in conditional; all we supply is the expression.

good_movies = movie_ratings.select do |m, r|
    r > 3
end

If may be that the SCT is checking the code but does not have an appropriate error message.


#4

thanks all that solved my problem


#5

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