Please enlighten me how am i supposed to check if the movie it's already in the array
It's explained in the instructions:
If the movie isn't already in the hash (that is, if
Which means that you'll need to create a conditional statement with this as a condition.
Like my friend arjofocolovi said it is well said in the inscructions let me just detailed it :
There is a method in ruby called .nil?. So what this method can do ? Well it checks a variable if it is nil, if its it will return true and if not it will return false for example :
whatever = nil
name = "Mahdi"
Here we can see that the whatever variable is "empty", it has a nil in it and the name variable is actually has something in it, in my exemple it has my name "Mahdi"
So now we know that the .nil? method return true if a variable have nothing in it and false if that same variable have something in it. M'kay ?
So if I call this method on my variable like : variable.nil? it will return... true ? why is that ? because it is "empty"
but if I call it on my name variable like : name.nil? it will return... YES! you got it : FALSE ! why ? because it has something in it.
Now let's return to our exercice, basically we want to check if the movie wanted to be added is already on our movies hash or not right ?
So if it is already add in it, if we call the .nil? method on it, it will return = false like we said earlier but if not it will return true ok ?
So how to do that ? well it is already said in the instructions box :
Here we ask ruby if the movie that the user want to add is already in our hash or not, get it ?
Then after that if we will add a code, can you guess it ?