Search Results

Search found 12457 results on 499 pages for 'variable assignment'.

Page 11/499 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • C++ variable alias - what's that exactly, and why is it better to turn if off?

    - by Poni
    I've read the essay Surviving the Release Version. Under the "Aliasing bugs" clause it says: You can get tighter code if you tell the compiler that it can assume no aliasing.... I've also read Aliasing (computing). What exactly is a variable alias? I understand it means using a pointer to a variable is an alias, but, how/why does it affect badly, or in other words - why telling the compiler that it can assume no aliasing would get me a "tighter code"

    Read the article

  • Javascript clears a variable after there is no further reference it

    - by Praveen Prasad
    It is said, javascript clears a variable from memory after its being referenced last. just for the sake of this question i created a JS file with only one variable; //file start //variable defined var a=["Hello"] //refenence to that variable alert(a[0]); // //file end no further reference to that variable, so i expect javascript to clear varaible 'a' Now i just ran this page and then opened firebug and ran this code alert(a[0]); Now this alerts the value of variable, If the statement "Javascript clears a variable after there is no further reference it" is true how come alert() shows its value. Is it because all variable defined in global context become properties of window object, and since even after the execution file window objects exist so does it properties.

    Read the article

  • Set environment variable in Ubuntu

    - by Junho Park
    In Ubuntu, I'd like to switch my JAVA_HOME environment variable back and forth between Java 5 and 6. I open a terminal and type in the following to set the JAVA_HOME environment variable: export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun And in that same terminal window, I type the following to check that the environment variable has been updated: echo $JAVA_HOME And I see /usr/lib/jvm/java-1.5.0-sun which is what I'm expecting to see. In addition, I modify ~/.profile and set the JAVA_HOME environment variable to /usr/lib/jvm/java-1.5.0-sun. And now for the problem--when I open a new terminal window and I check my JAVA_HOME environment variable by typing in echo $JAVA_HOME I see that my JAVA_HOME environment variable has been reverted back to Java 6. When I reboot my machine (or log out and back in, I suppose) the JAVA_HOME environment variable is set to Java 5 (presumably because of the modification I made in my ~/.profile). Is there a way around this so that I can change my JAVA_HOME environment without having to log out and back in (AND make that environment variable change stick in all new terminal windows)?

    Read the article

  • How to improve variable overriding/overwriting in XSL?

    - by ChrisBenyamin
    I want to do the following: Declare a variable Go into a if-statement Overwrite the variable XSL says I can't declare a variable twice, so what can I do to improve this step? Another approach was to check if a variable is set at all. I did this, because i skipped the first step and declared the variable in the if-statement. In another if-statement I wanted to check if the variable exists at all.

    Read the article

  • call value inside a JS variable as a JS function name

    - by user1640668
    Hello I have a function to perform actions but name of the function is inside a variable... below code will get the URL's hashed part example: #JHON and remove # and store it inside URLHASH variable..example: JHON var urlhash = document.location.hash; urlhash = urlhash.replace(/^.*#/, ''); always there is a function name from that value inside variable and i want to call value inside that variable as a function name window.onload=function() { Value inside URLHASH variable should run as a name of a variable. example: jhon(); }; Is it possible ? I tried some codes but it calls variable name as a function not value inside the variable..help me..

    Read the article

  • Conflict between variable substitution and CJK characters in BASH

    - by AndreasT
    I encountered a problem with variable substitution in the BASH shell. Say you define a variable a. Then the command $> echo ${a//[0-4]/} prints its value with all the numbers ranged between 0 and 4 removed: $> a="Hello1265-3World" $> echo ${a//[0-4]/} Hello65-World This seems to work just fine, but let's take a look at the next example: $> b="?1265-3?" $> echo ${b//[0-4]/} ?1265-3? Substitution did not take place: I assume that is because b contains CJK characters. This issue extends to all cases in which square brackets are involved. Surprisingly enough, variable substitution without square brackets works fine in both cases: $> a="Hello1265-3World" $> echo ${a//2/} Hello165-3World $> b="?1265-3?" $> echo ${b//2/} ?165-3? Is it a bug or am I missing something? I use Lubuntu 12.04, terminal is lxterminal and echo $BASH_VERSION returns 4.2.24(1)-release. EDIT: Andrew Johnson in his comment stated that with gnome-terminal 4.2.37(1)-release the command works fine. I wonder whether it is a problem of lxterminal or of its specific 4.2.24(1)-release version.

    Read the article

  • Variable naming conventions?

    - by Ziv
    I've just started using ReSharper (for C#) and I kind of like its code smells finder, it shows me some things about my writing that I meant to fix a long time ago (mainly variable naming conventions). It caused me to reconsider some of my naming conventions for methods and instance variables. ReSharper suggests that instance variable be lower camel case and begin with an underscore. For a while I meant to make all my local variables lower camel case but is the underscore necessary? Do you find it comfortable? I don't like this convention but I also haven't tried it yet, what is you opinion of it? The second thing it prompted me to re-evaluate is my naming conventions for GUI event handlers. I usually use the VS standard of ControlName_Action and my controls usually use hungarian notation (as a suffix, to help clarify in code what is visible to the user and what isn't when dealing with similarly named variable) so I end up with OK_btn_Click(), what is your opinion of that? Should I succumb to the ReSharper convention or there are other equally valid options?

    Read the article

  • Need help with the naming convention for an incremental variable [closed]

    - by iStryker
    I am using a voting module, that allows you vote either up or down [or reset]. If you vote up, the value is +1. If you vote down, the value is -1. If you vote up then down, the value is -1. I want to extend this module to allow you to vote multiple times, and the votes to be incremental. Examples Up, Up = +1, +1 = +2 Up, Up, Down = +1, +1, -1 = +1 I want to create a new boolean variable. If FALSE/NULL then use the old system +1/-1. If TRUE, voting will be incremental. What should be the name of this variable be? I feel 'incremental' is not the correct name. This module is part of an open-source project and is used on 3,177+ websites, so I want to get the naming convention right. Naturally, I'll be setting an upper and lower limit the variable be. [ie 5 & 0] Side-question: Is there a mathematics term to describe something being either +1/-1?

    Read the article

  • Python lower_case_with_underscores style convention: underscores not popular?

    - by squirrel
    PEP8 recommends using lowercase, with words separated by underscores as necessary to improve readability for variable and function names. I've seen this interpreted as lower_case_with_underscores by most people, although in practice and in Python's native methods it seems like lowercasewithoutunderscores is more popular. It seems like following PEP8 strictly would be awkward since it seems to suggest mixing both lower_case_with_underscores and lowercasewithoutunderscores, which would be inconsistent. What is your interpretation of PEP8's variable names, and what do you actually use in practice? (Personally, I like lowerCamelCase as a compromise between readability and ease of typing.)

    Read the article

  • IP assignment in a /28 block

    - by mks
    Need help on setting up firewall router. My config is as below: Public static network ID: x.x.x.48/28 gateway: x.x.x.49 available IP for the hosts: x.x.x.52 to 62 gw_eth0 <-- fw_eth0 - fw_eth1 <-- dmz_switch Four servers are connected on dmz_switch (say s1, s2, s3, s4) all have to use public static IP address from the above block. Any recommendation on IP assignment and route setup? Do I need to subnet the above block further or simply use /32 netmask and point-to-point static routes in the above setup?

    Read the article

  • Personal Virtual Desktop Collection: User Assignment

    - by Fitzroy
    Using Windows Server 2012 Remote Desktop Services, I have a 'Personal Virtual Desktop Collection' with automatic user assignment enabled. According to Microsoft "Personal virtual desktops are permanently assigned to a user account and the user logs on to the same virtual desktop each time." Is there a way either through the Server Manager UI or PowerShell to determine which user has been assigned to which VM? The only way I have found so far is to query the 'Remote Desktop Users' group on each VM in the collection, however that requires each VM to be powered on. There must be a better way.

    Read the article

  • PHP application variable... maybe?

    - by James
    I went to a PHP job interview, I was asked to implement a piece of code to detect visitors are bots to crawl thru the website and steal content. So I implemented a few lines of code to detect if the site is being refreshed/visited too quickly/often by using a session variable to store last visit timestamp. I got told that session varaibles can be manupilated by cookies etc, so I am wondering if there is a application variable that I can use to store the timestamp information against visitor IPs eg $_SERVER[REMOTE_ADDR]? I know that I can write the data to a file but it's not very good for a high traffic website. Regards James

    Read the article

  • Have loaded a php variable into flash but cant apply it in a function...

    - by Paul Elliot
    hi I have created an actionscript function which stops an animation on a specific frame which works fine. I have then loaded in a php file with a variable which will contain the number for the frame i want the animation to stop on. This has loaded in fine and i have loaded it in a function. what i cant seem to do is to get the variable into the function which tells the animation to stop playing. here is my code: //load variables varReceiver = new LoadVars(); // create an object to store the variables varReceiver.load("http://playground.nsdesign6.net/percentage/external.php"); //load variables //function1 varReceiver.onLoad = function() { //value is the var that is created. var paul = this.percentage; } //function1 //function2 this.onEnterFrame = function() { if(this._currentframe==(percentage)) { this.stop(); this.onEnterFrame = undefined; } } play(); //function2 cheers paul

    Read the article

  • In C++, what is the "order of precedence" for shadowed variable names?

    - by Emile Cormier
    In C++, what is the "order of precedence" for shadowed variable names? I can't seem to find a concise answer online. For example: #include <iostream> int shadowed = 1; struct Foo { Foo() : shadowed(2) {} void bar(int shadowed = 3) { std::cout << shadowed << std::endl; // What does this output? } int shadowed; }; int main() { Foo().bar(); } I can't think of any other scopes where a variable might conflict. Please let me know if I missed one.

    Read the article

  • Can I have two names for the same variable?

    - by Roman
    The short version of the question: I do: x = y. Then I change x, and y is unchanged. What I want is to "bind" x and y in such a way that I change y whenever I change x. The extended version (with some details): I wrote a class ("first" class) which generates objects of another class ("second" class). In more details, every object of the second class has a name as a unique identifier. I call a static method of the first class with a name of the object from the second class. The first class checks if such an object was already generated (if it is present in the static HashMap of the first class). If it is already there, it is returned. If it is not yet there, it is created, added to the HashMap and returned. And then I have the following problem. At some stage of my program, I take an object with a specific name from the HashMap of the first class. I do something with this object (for example change values of some fields). But the object in the HashMap does not see these changes! So, in fact, I do not "take" an object from the HashMap, I "create a copy" of this object and this is what I would like to avoid.

    Read the article

  • Is it a good idea to define a variable in a local block for a case of a switch statement?

    - by Paperflyer
    I have a rather long switch-case statement. Some of the cases are really short and trivial. A few are longer and need some variables that are never used anywhere else, like this: switch (action) { case kSimpleAction: // Do something simple break; case kComplexAction: { int specialVariable = 5; // Do something complex with specialVariable } break; } The alternative would be to declare that variable before going into the switch like this: int specialVariable = 5; switch (action) { case kSimpleAction: // Do something simple break; case kComplexAction: // Do something complex with specialVariable break; } This can get rather confusing since it is not clear to which case the variable belongs and it uses some unnecessary memory. However, I have never seen this usage anywhere else. Do you think it is a good idea to declare variables locally in a block for a single case?

    Read the article

  • Is it bad practice to initialize a variable to a dummy value?

    - by froadie
    This question is a result of the answers to this question that I just asked. It was claimed that this code is "ugly" because it initializes a variable to a value that will never be read: String tempName = null; try{ tempName = buildFileName(); } catch(Exception e){ ... System.exit(1); } FILE_NAME = tempName; Is this indeed bad practice? Should one avoid initializing variables to dummy values that will never actually be used? (EDIT - And what about initializing a String variable to "" before a loop that will concatenate values to the String...? Or is this in a separate category? e.g. String whatever = ""; for(String str : someCollection){ whatever += str; } )

    Read the article

  • Array Assignment

    - by Mahesh
    Let me explain with an example - #include <iostream> void foo( int a[2], int b[2] ) // I understand that, compiler doesn't bother about the // array index and converts them to int *a, int *b { a = b ; // At this point, how ever assignment operation is valid. } int main() { int a[] = { 1,2 }; int b[] = { 3,4 }; foo( a, b ); a = b; // Why is this invalid here. return 0; } Is it because, array decays to a pointer when passed to a function foo(..), assignment operation is possible. And in main, is it because they are of type int[] which invalidates the assignment operation. Doesn't a,b in both the cases mean the same ? Thanks. Edit 1: When I do it in a function foo, it's assigning the b's starting element location to a. So, thinking in terms of it, what made the language developers not do the same in main(). Want to know the reason.

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >