As per the notes given:
“Global variables can be declared in two ways. The first is one that’s already familiar to you: you just define the variable outside of any method or class, and voilà! It’s global. If you want to make a variable global from inside a method or class, just start it with a $, like so: $matz.”
If I am trying to do the following to create a Global Variable by defining it outside the method it doesn’t work
Tried different things, and it seems you have to use the “$” regardless of the place you define it.
I think that what they mean by making it global by “defining the variable outside of any method or class”, is that it’s indeed global for the program, but except for methods and classes. If you want to make it global to every single part of the program, you have no other choice than using “$”. At least that’s what I think.
You are completely right I must have omitted it somehow. One of the next exercises showed me that if I define some variable with @, @@ or $ before the name I need to use them then calling that variables.