Skip to main content

Questions tagged [local-variable]

A variable whose scope is contained to a smaller unit of code such as a function or class.

0 votes
5 answers
464 views

Lately, I have been playing with this idiom: Changing a private member variable into a local static variable when: member to singleton class used in only one function member is mutex for a shared ...
Anon's user avatar
  • 3,649
1 vote
2 answers
364 views

In Common Lisp, we have to use the let form to declare a new lexically-scoped variable. This means that the code either looks like that written in C89 (all variables declared on top of scope), or ...
ndsrib's user avatar
  • 19
0 votes
2 answers
359 views

coders. I'm learning C programming language and found out such thing as #define directive that allows us to use symbolic constants (following Brain Kernigan). I know that this directives "insert&...
CoderDesu's user avatar
  • 1,015
0 votes
2 answers
1k views

On Stack Overflow I frequently see questions with code in the following style: function funcName(parameter) { let variable = parameter; // rest of function uses variable rather than parameter } ...
Barmar's user avatar
  • 346
2 votes
4 answers
2k views

Context: Java, fairly new developer I have inherited code from a friend for a project that processes variables. The first thing i notice is the class has a ton of member variables. I have always been ...
Ian's user avatar
  • 137
37 votes
8 answers
10k views

According to the accepted answer on "Rationale to prefer local variables over instance variables?", variables should live in the smallest scope possible. Simplify the problem into my interpretation, ...
ocomfd's user avatar
  • 5,760
-2 votes
2 answers
344 views

For example, sometimes I need a float variable to be used inside a for loop, e.g.: float sum=0; for(int i = 0; i < students.length; i++) { sum += Math.random(); students[i].result = sum; } ...
ocomfd's user avatar
  • 5,760