Scope is an enclosing context where values and expressions are associated. Use this tag for questions about different types of scope as well for questions where scope may be unclear.
Questions tagged [scope]
17524 questions
5
votes
5 answers
T-SQL EXEC and scope
Let's say I have a stored procedure with this in its body:
EXEC 'INSERT INTO ' + quotename(@table) ' blah...'
SELECT IDENT_CURRENT('' + @table + '')
Is IDENT_CURRENT() guaranteed to get the identity of that row INSERTed in the EXEC? IDENT_CURRENT()…

core
- 32,451
- 45
- 138
- 193
5
votes
8 answers
local scope in Java
Why is it that curly braces do not define a separate local scope in Java? I was expecting this to be a feature common to the main curly brace languages (C, C++, Java, C#).
class LocalScopeTester
{
public static void main(String... args)
{
…

H2ONaCl
- 10,644
- 14
- 70
- 114
5
votes
2 answers
Complex Scope, Rails 3
So I am building an application that matches users. User models have 3 attributes (that are relevant to my question anyways: gender:string, looking_for_men:boolean, looking_for_women:boolean.
currently I've got a method in my model like so:
def…

goddamnyouryan
- 6,854
- 15
- 56
- 105
5
votes
2 answers
how to distingish between local and static variables of same name
example to illustrate :
public class Something
{
private static int number;
static Something()
{
int number = 10;
// Syntax to distingish between local variable and static variable ?
}
}
Inside the static…

Moe Sisko
- 11,665
- 8
- 50
- 80
5
votes
2 answers
Passing local variable with name of a global variable isn't possible in JS?
foo = "foobar";
var bar = function(){
var foo = foo || "";
return foo;
}
bar();`
This code gives a result empty string. Why cannot JS reassign a local variable with same name as a global variable? In other programming languages the expected…

GirginSoft
- 375
- 3
- 16
5
votes
2 answers
Javascript apply or call used on charCodeAt
The premise: what the correct charCodeAt(i : Int) performance would look like:
"test".charCodeAt(0)
116
"test".charCodeAt(1)
101
"test".charCodeAt(2)
115
"test".charCodeAt(3)
116
"test".charCodeAt(4)
NaN
and here what happens when when using call…

Lorenz Lo Sauer
- 23,698
- 16
- 85
- 87
5
votes
2 answers
Using Public Final Member Variables and Overridable Methods in a Constructor
I have questions about a couple techniques I'm using in designing a class. I've declared some of its members as public final instead of private, and the constructor calls overridable methods. I know that these are normally considered bad practice,…

Kevin
- 14,655
- 24
- 74
- 124
5
votes
2 answers
With Svelte : How to put component style in a separated file but still scoped to this component
I'm working on a table component which one will be usable (included in a library when it will work correctly)in any of my projects.
As there is a lot of css rules related to this component I would like to put the style outside of the component…

Alain BUFERNE
- 2,016
- 3
- 26
- 37
5
votes
4 answers
Is there a way to access the value of a local variable that has become hidden inside another scope?
I know if a variable is global, the you can always access its value by preceding the variable name with ::... but is there a way to access the value of a local variable that has become hidden inside another scope?
I thinking of something like…

Jimmy
- 4,419
- 6
- 21
- 30
5
votes
3 answers
C#: Definition of the scope of variables declared in the initialization part of for-loops?
Possible Duplicates:
confused with the scope in c#
C# Variable Scoping
I am curious about the design considerations behind the scope of variables which are declared in the initialization part of for-loops (etc). Such variables neither seem to be…

Avada Kedavra
- 8,523
- 5
- 32
- 48
5
votes
5 answers
Objective-C: correct method for passing
How can you pass around a variable amongst methods?
I have a UITabBarController.
- (void)tabBarController:(UITabBarController *)tabBarController
didSelectViewController:(UIViewController *)viewController {
NSLog(@"my ns string %@",…

Michael
- 309
- 2
- 3
- 16
5
votes
2 answers
How do modules and scope interact when the same module is imported into the same environment multiple times?
Imagine we have modules A, B, and C, and that module C has some variable X at module scope.
A imports B, which (for its own purposes) imports C. A also directly imports C.
If A changes the value of C.X, does that change the value of C.X that B sees?…

enkiv2
- 166
- 1
- 8
5
votes
1 answer
Accessing outside of class's namespace inside class method?
I have a header resource that I'm making use of that defines a struct called
typedef struct { ... } Mii;
Now, in my own program, I'm writing a wrapper class that uses this struct privately and internally for its own operations, so I put my class…

cemulate
- 2,305
- 1
- 34
- 48
5
votes
4 answers
Why doesnt Pythons += (plus equals) operator modify variables from inner functions?
I would like to know details about why this doesn't work as expected:
def outer():
mylist = []
def inner():
mylist += [1]
inner()
outer()
Especially because mylist.__iadd__([1]) works fine.

nh2
- 24,526
- 11
- 79
- 128
5
votes
2 answers
Is it able to inject RequestScope bean into Singleton bean using Constructor Injection in Spring?
It is working as far as I tested. But I do not get it why and how it works.(Also I am not sure it is safe to use in production)
Here is my testCode
@Service
public class SomeService {
private static final Logger logger =…

Juneyoung Oh
- 7,318
- 16
- 73
- 121