Bug Report



I think I've found a bug in Ruby Hashes & Symbols | Becoming More Selective.

My code is:
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

good_movies = movie_ratings
good_movies.select {|n, r| r > 3}

The console displays:
{:primer=>3.5, :the_matrix=>5, :truman_show=>4, :skyfall=>4, :lion_king=>3.5}

But I get the error:
Oops, try again. It looks like good_movies includes memento, but it shouldn't.

Am I missing something here? 'menento' is not displayed in the console.



This is a very late reply. This is not a bug. What you have done here is demonstrate that select does not modify the hash.

The Ruby console is displaying the results of your last command

good_movies.select {|n, r| r > 3}

but you have not changed the value of good_movies. If you print good_movies you will see that it is unchanged.