What kind of variable is time?


#1

When I defined the variable time inside the method create, it doesn't use @, @@ nor $. What does it mean? Can I access that variable anytime or only inside that method or class?


#2

If you mean something like this

def create
time = 1
end

Then the variable can be called upon from anywhere, and is a global variable.

EDIT: It's a local variable, my mistake.


#3

@tehluigi
K I don't really know any ruby, but I would claim that is local to that function, not global

It would return 1 though, since the assignment itself evaluates to 1 and it's the last line of the function/method


#4

Whoops—I got my local and global variables mixed up.