Questions tagged [global]

Refers to a space where variables and other items may be accessed from any scope.

4669 questions
21
votes
4 answers

Global Variables performance effect (c, c++)

I'm currently developing a very fast algorithm, with one part of it being an extremely fast scanner and statistics function. In this quest, i'm after any performance benefit. Therefore, I'm also interested in keeping the code "multi-thread"…
Cyan
  • 13,248
  • 8
  • 43
  • 78
21
votes
2 answers

How to set global repositories for gradle that I can use them in each gradle project

It's slow to visit the maven official repositories from my country, so I want to try some local repositories first. Is it able to add them to some global gradle configuration file, that I can just use them in each gradle project, without modifying…
Freewind
  • 193,756
  • 157
  • 432
  • 708
21
votes
2 answers

npm won't install packages locally. What's wrong?

I want to install packages locally, but npm is always installing packages to the global location. I'm running the following command: npm install serialport I do not have a .npmrc command and I'm not using the -g flag, so I don't know why it's not…
user1449536
  • 301
  • 1
  • 3
  • 7
20
votes
2 answers

Jenkins: Access global passwords in powershell

I am having trouble accessing the jenkins global password as an environment variable in powershell. I have done the following. Not sure what else I am missing. Installed Credentials Binding Plugin, Environment Injector Plugin, Mask Passwords…
user4296485
  • 201
  • 1
  • 2
  • 3
20
votes
3 answers

Declaring a global array

Hi. I recently learned PHP and am trying to declare a global array so I can access inside a function. But I seem to be missing something because I get the error 'Undefined variable:' Here is my code: global $second_array; $second_array =…
Nistor Alexandru
  • 5,309
  • 9
  • 46
  • 71
19
votes
7 answers

How can global function exist in C#?

How can global function exist in C# when everything is defined inside a class? I was reading the documentation of OpCodes.Call at MSDN, and was surprised to see the following wordings, The metadata token carries sufficient information to determine…
Nawaz
  • 353,942
  • 115
  • 666
  • 851
19
votes
8 answers

Declaring global variable with php.ini

Is it possible to keep variables in php.ini file. Like that we do with the web.config in .net. I like to keep a flag type variable in the php.ini and use it to different projects.
Zstream
  • 205
  • 1
  • 2
  • 6
19
votes
4 answers

The good, the bad, and the ugly of lexical $_ in Perl 5.10+

Starting in Perl 5.10, it is now possible to lexically scope the context variable $_, either explicitly as my $_; or in a given / when construct. Has anyone found good uses of the lexical $_? Does it make any constructs simpler / safer /…
Eric Strom
  • 39,821
  • 2
  • 80
  • 152
19
votes
3 answers

Difference between static and const variables

what is the difference between "static" and "const" when it comes to declare global variables; namespace General { public static class Globals { public const double GMinimum = 1e-1; public const double GMaximum = 1e+1; …
Ibrahim Ozdemir
  • 613
  • 1
  • 5
  • 18
19
votes
6 answers

Global variable in laravel 4

I was wondering how to do a global variable to save me few lines of copy and pasting this lines. Array it probably and put them in one variable instead? I want to use this variable in other routes. $providerEmail = Auth::user()->email; …
nCore
  • 2,027
  • 7
  • 29
  • 57
18
votes
4 answers

What is meant by “leaking” into global scope?

A while ago, I offered-up a JavaScript design pattern (the Module Pattern - see below) that I got from a John Resig example as part of a solution to someone’s question and I received the following comment: “…that pattern is a bit over engineered…
Prisoner ZERO
  • 13,848
  • 21
  • 92
  • 137
18
votes
3 answers

Are global variables extern by default or is it equivalent to declaring variable with extern in global?

I have gone through following two questions: static and extern global variables in C and C++ global variable in C are static or not? Both questions says the two things in different way. Question 1's Answer: Global variables are not extern nor…
VINOTH ENERGETIC
  • 1,775
  • 4
  • 23
  • 38
18
votes
4 answers

Change Button color onClick

I want my Button to change color every time I click on it. But it only changes color on the first click. I believe the problem is in the setColor function. Every time I click on the Button, count gets set to 1. So even when I set it to 0, it gets…
user2456977
  • 3,830
  • 14
  • 48
  • 87
18
votes
1 answer

What is the root object in Node.js

You may know the global object in Node.js: {Object} The global namespace object. In browsers, the top-level scope is the global scope. That means that in browsers if you're in the global scope var something will define a global variable. In…
borisdiakur
  • 10,387
  • 7
  • 68
  • 100
18
votes
5 answers

Call function from string in nodejs

What is the equivalent to window[my_func_name] in nodejs? I'm reading a string from stdin and if it's a function name I want to execute it. I thought global[my_func_name] might work but unfortunately it doesn't.
PaulK
  • 623
  • 2
  • 10
  • 22