Questions tagged [local-variables]

Local variables have a limited scope, generally one function or one functional block.

Local variables have a limited scope, generally one function or one functional block.

Compare with global variables, which are accessible from any part of a program.

1302 questions
0
votes
3 answers

Undefined local variable for hash in method ruby

for some reason I'm getting NameError: undefined local variable or method `states' for main:Object though states is clearly defined. What is going on here? In irb I added states in and accessed it fine using states[:CA] but when I put it in a…
MikaAK
  • 2,334
  • 6
  • 26
  • 53
0
votes
1 answer

Why is this local variable inside for loop in Javascript look like its being reused instead of recreated every loop?