Search Results

Search found 13794 results on 552 pages for 'variable scope'.

Page 15/552 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Why does the Java compiler complain about a local variable not having been initialized here?

    - by pele
    int a = 1, b; if(a > 0) b = 1; if(a <= 0) b = 2; System.out.println(b); If I run this, I receive: Exception in thread "main" java.lang.Error: Unresolved compilation problem: The local variable b may not have been initialized at Broom.main(Broom.java:9) I know that the local variables are not initialized and is your duty to do this, but in this case, the first if doesn't initialize the variable?

    Read the article

  • 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

  • RSpec and stubbing parameters for a named scope

    - by Andy Waite
    I'm try to write a spec for a named scope which is date dependent. The spec: it "should return 6 months of documents" do Date.stub!(:today).and_return(Date.new(2005, 03, 03)) doc_1 = Factory.create(:document, :date => '2005-01-01') Document.past_six_months.should == [doc_1] end The named scope in the Document model: named_scope :past_six_months, :conditions => ['date > ? AND date < ?', Date.today - 6.months, Date.today] The spec fails with an empty array, and the query in test.log shows why: SELECT * FROM "documents" WHERE (date > '2009-11-11' AND date < '2010-05-11') i.e. it appears to be ignoring my stubbed Date method. However, if I use a class method instead of a named scope then it passes: def self.past_six_months find(:all, :conditions => ['date > ? AND date < ?', Date.today - 6.months, Date.today]) end I would rather use the named scope approach but I don't understand why it isn't working.

    Read the article

  • Why does my Workflow Service (4.0) variable go null in a DoWhile Activity?

    - by jlafay
    I have a WF service that I'm trying to setup receive activities to "Subscribe" and "Unsubscribe". I'm using This WF Durable Duplex Tutorial as a basis because my service performs callbacks to clients. Basically, think of it as a chat service. I can make client calls to the two receive activities just fine. What happens is the callback address of the client is passed in to Subscribe() on the service. The address is stored as a variable in the WF service and everything looks like it would work as to be expected. When a client calls Unsubscribe(), my watch I have set on the address var during debugging shows it as null. So what gives? Here's the basic setup of my WF service layout... Everything is enveloped in a DoWhile activity. Inside of that is a Pick activity and two Pick branches. The first branch is for subscribing activities. It has a receive-sendreply activity that assigns the string passed by the client to the WF address var. The second branch handles unsubscribing. The trigger is the Request activity and the client address is again passed in. From there it goes into a sequence, starting with an If. It checks to see if the unsubscribeAddress equals the address already subscribed. If it does, then it sets the address to String.Empty and sends a success message back to the client. Why would a variable that's scoped to the enveloping DoWhile activity be implicitly assigned to null? I'm trying to get this to work so I can implement multiple client subscribers from there and work on triggers that invoke callbacks to multiple clients. CONCAT EDIT: I set a breakpoint at the DoWhile level and my var is null once Unsubscribe() is called. When Subscribe() is invoked, the watch shows a value in the var all the way through. Until I Unsubscribe() with a client. Should I be using a While Activity instead?

    Read the article

  • using pom for test scope dependencies

    - by IttayD
    Hi, Is it possible to create a pom file so it can be used inside another pom to add test scope dependencies? So in module E's pom.xml I have: <dependencies> <dependency> <groupId>com.example</artifactId> <artifactId>D</artifactId> <type>pom</type> <scope>test</scope> </dependency> </dependencies> So that if D's pom.xml contains dependencies on artifacts A, B, C, then these artifacts are in the compilation and execution classpath of E's tests. NOTE: the reason I want such a pom, and not rely on regular dependency resolution is that I have created a tests jar using maven-jar-plugin:test-jar and using that jar as a dependency causes maven to not use its transitive dependencies. (see http://jira.codehaus.org/browse/MNG-1378) UPDATE: this does not work for me (maybe because I'm trying to use it for the test scope): http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-pom-best-practice.html

    Read the article

  • How to change scope data in controller?

    - by Derooie
    I am a real newbie at angular. I created something now which will let me retrieve and add items via angular and get/put them in mongodb. I use express and mongoose in the app The question is, how can i modify the data before it reaches the DOM in the controller. In this example i have created a way to retrieve data, and i get it exactly as it is stored in mongodb. What i would like is that the field where i store 1 or 0 in the database, to be shown as text. So if mongo has a value 1 i get "the value in mongo is 1" and when the field has a value of 0 get "the value is zero". (just as an example, i like other texts, but it illustrate what i want) I post my controller, html and current output. Any help would be appreciated. Controller function getGuests($scope, $http) { $scope.formData = {}; $http.get('/api/guests') .success(function(data) { $scope.x = data; }) .error(function(data) { console.log('Error: ' + data); }); } HTML <div ng-controller="getGuests"> <div ng-repeat="guest in x"> {{ guest.voornaam }} {{ guest.aanwezig }} </div> </div> The current scope output, what i see in HTML. I like to change only the value of "aanwezig" in case the value of aanwezig is 0 or 1. firstname1 1 firstname2 0 Something else, but would be great to learn, is how i can do a specific mongodb query by the push of a button and get that result.

    Read the article

  • Apache: scope for environmental variables

    - by Anonymous
    While there's documentation available on Apache environmental variables, I can not find answer to one important question. Imagine I use rewrite rules to set environmental variable RewriteRule ... ... [E=something:1] What is the scope of "something" - global Apache server (this means "something" will be available for other request transactions), this request (means that "something" is only valid for THIS http request (and its related processing - but what's about internal redirects and other internal stuff - are they considered as THIS request, or another one?), and may be set differently within another (concurrent) request?

    Read the article

  • iPhone development: Best method to allow user to chose search scope

    - by Mark Pemburn
    Hi, I'm developing my first iPhone app and want to allow the user to select the scope of their search in a more complex way than the 'scope buttons' permit. The app is related to wines and I want to the user to be able to select the 'color' (Red, White, Blush, etc.) first, and then select the type/varietal within that category. Right now, I'm using the UISearchBar's scope buttons for the colors and tapping the button opens a view with the selection of colors. This is okay except that once the 'Red' button has been selected, I can't select it a second time to change my choice of type (e.g., change from 'Merlot' to 'Syrrah', etc.) If there's a better way to do this, I'm willing to scrap my method and start from scratch. Thanks!

    Read the article

  • ASP.NET variable scope

    - by c11ada
    hey all, im really new to ASP.Net and still havnt got my head round most of the concepts, im really having problems with variable, when creating a desktop application, any variable created in code for example int n = 10; this variable will be there until the program is running right. but in asp iv created variables which are supposed to last until the user gets of that page, so for example say i have a page which takes the users value ( call this variable n say the user type in 10) and every time the user presses the next button the code add 10 to this value. so the first time the user presses the next button n= n + 10; what i have found is no matter how many times i press the next button n will always equal 20, because the previous value is not saved !! these values are populated the first time the user enters that page, once the user clicks the next button the content of these values disappear! how can stop this from happening ?? hope this makes sense !! thanks

    Read the article

  • How to call angular javascript directive methods from the global scope

    - by user1659278
    I have a directive like the one of the examples from AngularJS, shown below. How can I call the toggle method from the global scope? I want to be able to toggle the zippy from some legacy code. myApp.directive('zippy', function(){ return { restrict: 'E', replace: true, transclude: true, scope: { title:'bind' }, template: '<div class="zippy">' + '<div class="title">{{title}}</div>' + '<div class="body" ng-transclude></div>' + '</div>', link: function(scope, element, attrs) { var title = angular.element(element.children()[0]), opened = true; title.bind('click', toggle); function toggle() { opened = !opened; element.removeClass(opened ? 'closed' : 'opened'); element.addClass(opened ? 'opened' : 'closed'); } toggle(); } } });

    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

  • Using scope, defined in parent model, inside it's child (STI pattern)

    - by Anton
    I implement a class hierarchy using STI pattern class A scope :aaa, where([someField]:[someValue]) end class B < A end The problem is that when I try to call something like: B.limit(5).aaa => SELECT "[table]".* FROM "[table]" WHERE "[table]"."type" IN ('A') AND ([someField] = [someValue]) LIMIT 5 So I am getting 5 objects of type A, which satisfies scope :aaa But I need to do the same with rows where type = "B" Is there any way to use scopes from parent, without redifinning it in childs in STI pattern? Thanks in advance EDITED I just discussed it with my frind and he showed me one important thing. A in not the root class of STI. IN fact whole hierarchy looks like class O < ActiveRecord::Base end class A < O scope ..... ..... end class B < A end maybe the reason is in hierarchy itself?...

    Read the article

  • Rails Scope for association of 0 size.

    - by MissingHandle
    I'm having trouble figuring out the scope method for all the Foos that have no Bars. That is: class Foo < ActiveRecord::Base has_may :bars end class Bar < ActiveRecord::Base belongs_to :foo end I'd like to write a scope method that returns me all the foos that have no bars. Something like: class Foo < ActiveRecord::Base has_may :bars scope :has_no_bars, includes(:bars).where("COUNT(foo.bars) = 0") end But I don't understand the appropriate syntax. Any help? Happy to use a MetaWhere solution if easier.

    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

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >