Let’s add a method so that we could ask car1 which direction it is current going.
The method name will be
Here we run into the same issue. Method
current_direction can’t access
direction of method
turn method to store the
direction in an instance variable so that
current_direction can access that instance variable.
If we add
@ to a variable then that variable becomes
The special thing about an instance variable is that any instance method can access an instance variable.
In this case we are going to store the direction of the turn into an instance variable.