Erioifpuderio.hashnode.dev·Aug 3, 2024Rust 中的全局状态最近写 Rust 程序需要用到全局状态,我希望有一个状态在公共的作用域里,其他模块能通过引入等方式去访问他,在 JS 中做起来很简单: const globalState = { name: 'abc' } function foo() { console.log(globalState) } function bar() { globalState.name = '123' } 由于 JS 的限制较少,变量声明的位置没有限制,在代码顶部声明后,后续所有作用域都能使用。 在...Rust
Bear Evansblog.thebear.dev·Apr 14, 2024Global Variables in Unity with Scriptable ObjectsIn game development, you often find that you need to access a certain variable or object from many different places. Things like the score, the player's health, a user-configured setting, and more are frequently needed by many different components th...126 readsunity
Jyotiprakash Mishrablog.jyotiprakash.org·Dec 30, 2023Need globals without name collisions? Static at file level!In C programming, the static keyword can be used in different contexts. When static is used at the file level, also known as file scope or global scope, it gives the variable or function "internal linkage." This means that the variable or function is...C Programmingstatic variable
Jyotiprakash Mishrablog.jyotiprakash.org·Dec 30, 2023Let only one global live! The extern keywordTo demonstrate the use of the extern keyword with global variables in C, I'll create a simple example involving two source files. The extern keyword is used to declare a global variable in one file, which is defined in another. This approach allows m...C Programmingextern
Jyotiprakash Mishrablog.jyotiprakash.org·Dec 30, 2023Global variables are one of a kind!Global variables in programming are variables that are defined outside of any function and can be accessed from any part of the code within the same file or, in some cases, from other files as well. Unlike local variables that are created and destroy...C Programmingdata section
Raineraineyang.hashnode.dev·Dec 27, 2023Rust Learning Note: Global VariableThis article is a summary of Chapter 4.7 of Rust Course (course.rs/) Global Variables Initialized at Compile Time Static Constant Static constants are global constants that can be used anywhere in the program, regardless of the scope in which it is d...Rust
Cup of Solutionblog.pritamguha.com·Oct 16, 2023Python(Part - 2):Unlocking the Power of Python VariablesIntroduction : A variable is a type of container that stores values. You don't need to declare variables before using them or before declaring their type. Without assigning any values, the variable is completely useless. When we assign any value to a...42 readsPython
Giver Kdkgiver-kdk.hashnode.dev·Oct 14, 2023PHP: Function, Conditionals and ScopeFunction Definition A function is defined using the 'function' keyword similar to JavaScript. function myFun() { echo "Hello World"; } // Output: Hello World myFun(); Default Parameter The parameters in a function can be given a default value wh...39 readsConditional statement