undefined

JavaScript bitwise undefined pitfalls?

回眸只為那壹抹淺笑 提交于 2019-12-05 11:23:34
What is the logic of bitwise operators on undefined??? var x; console.log(x); // undefined console.log(x^7); // 7 console.log(7^x); // 7 console.log(x|7); // 7 console.log(7|x); // 7 console.log(7&x); // 0 console.log(x&7); // 0 console.log(~x); // -1 console.log(x*2); // NaN console.log(x/2); // NaN console.log(x+2); // NaN console.log(x-2); // NaN I can see some sense in NaN. Because undefined -2 is really 'not a number'. But I do not follow any logic on bitwise operators and undefined. The internal function [ToInt32] is called on all operands for all bitwise operators. Note that ToInt32

Undefined/Unspecified/Implementation-defined behaviour warnings?

ぐ巨炮叔叔 提交于 2019-12-05 10:51:16
Can't a compiler warn (even better if it throws errors) when it notices a statement with undefined/unspecified/implementation-defined behaviour? Probably to flag a statement as error, the standard should say so, but it can warn the coder at least. Is there any technical difficulties in implementing such an option? Or is it merely impossible? Reason I got this question is, in statements like a[i] = ++i; won't it be knowing that the code is trying to reference a variable and modifying it in the same statement, before a sequence point is reached. Alok Singhal It all boils down to Quality of

How to use angular 2 service which returns http promise

若如初见. 提交于 2019-12-05 10:04:23
I have a trouble with angular 2 here. I use service that return promise but when i try to retrive the response i got an error. i was read this this stact question this my code. this is HotelService.ts import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; //rxjs promises cause angular http return observable natively. import 'rxjs/add/operator/toPromise'; @Injectable() export class HotelService { private BASEURL : any = 'http://localhost:8080/hotel/'; constructor(private http: Http) {} load(): Promise<any> { return this.http.get(this.BASEURL + 'api/client/hotel/load')

'RTLD_NEXT' undeclared

。_饼干妹妹 提交于 2019-12-05 08:57:47
问题 I'm trying to compile a C program but I get the error 'RTLD_NEXT' undeclared. I think this is supposed to be defined in dlfcn.h which the c program includes, but when I looked inside dlfcn.h there is no RTLD_NEXT. How do I fix this? 回答1: The issue here is that RTLD_NEXT is not defined by the posix standard . So the GNU people don't enable it unless you #define _GNU_SOURCE or -D_GNU_SOURCE . Other relevant pieces of POSIX are dlfcn.h and dlsym.h. Interestingly, the later mentions RTLD_NEXT .

dynamic getter and setters - a possibility

三世轮回 提交于 2019-12-05 08:10:34
I am trying to solve a problem that came to my mind lately. Let's say we would want and would know how to make a point in having dynamic getters and setters in javascript, more like those in php (__get, __set). But as javascript does not have a catch-all property the only thing we could do is to provide a list of possible keys and iterate to add getters and setters on those only, and hope none other will ever come. But the problem is not by far solved. So the next approach that came to my mind was to use a nasty hack with try and catch , so anytime a name would be undefined in an object to use

PHP Undefined Constant PHP_ROUND_HALF_DOWN

元气小坏坏 提交于 2019-12-05 06:10:21
I have some PHP code in a project I'm working on that uses PHP's round function. On my localhost, I don't include any quotes around my mode argument, stating it as just PHP_ROUND_HALF_DOWN. However, when pushing to my server I get the error message: Use of undefined constant PHP_ROUND_HALF_DOWN - assumed 'PHP_ROUND_HALF_DOWN' Warning (2): Wrong parameter count for round() [APP/views/helpers/time_left.php, line 14] Now, when I add the single quotes to the mode argument, the first error goes away, however the "wrong parameter count" remains. I'm calling the function as follows: $days = round((

Why in Ruby, a || 1 will throw an error when `a` is undefined, but a = a || 1 will not?

懵懂的女人 提交于 2019-12-05 05:26:44
When a is undefined, then a || 1 will throw an error, but a = a || 1 will not. Isn't that a little bit inconsistent? irb(main):001:0> a NameError: undefined local variable or method 'a' for main:Object from (irb):1 from c:/ruby/bin/irb:12:in '<main>' irb(main):002:0> a || 1 NameError: undefined local variable or method 'a' for main:Object from (irb):2 from c:/ruby/bin/irb:12:in '<main>' irb(main):003:0> a = a || 1 => 1 a Here, you are evaluating a , which isn't defined. Therefore, you get an exception. a || 1 Here, you still have to evaluate a to determine the value of the boolean expression.

c++ undefined reference to static variable [duplicate]

☆樱花仙子☆ 提交于 2019-12-05 05:18:45
This question already has an answer here: static variable link error 2 answers I have no idea why this code isn't working. All the source files compile but when I try to link them the compiler yells at me with an undefined reference error. Here's the code: main.cpp: #include "SDL/SDL.h" #include "Initilize.cpp" int main(int argc, char* args[]) { //Keeps the program looping bool quit = false; SDL_Event exit; //Initilizes, checks for errors if(Initilize::Start() == -1) { SDL_Quit(); } //main program loop while(quit == false) { //checks for events while(SDL_PollEvent(&exit)) { //checks for type

Is there a way to handle undefined functions being called in JavaScript?

南楼画角 提交于 2019-12-05 04:03:31
If I have a function like the following: function catchUndefinedFunctionCall( name, arguments ) { alert( name + ' is not defined' ); } and I do something silly like foo( 'bar' ); when foo isn't defined, is there some way I can have my catch function called, with name being 'foo' and arguments being an array containing 'bar'? There is in Mozilla Javascript 1.5 anyway (it's nonstandard). Check this out: var myObj = { foo: function () { alert('foo!'); } , __noSuchMethod__: function (id, args) { alert('Oh no! '+id+' is not here to take care of your parameter/s ('+args+')'); } } myObj.foo(); myObj

How to display space instead undefined and null in vue.js template?

佐手、 提交于 2019-12-04 22:35:31
问题 This is Vue.js template <strong>{{userdata.phone}}</strong> When userdata.phone == null or userdata.phone == undefined, I would like to show space. for example <strong> {{ userdata.phone | !null | !undefined }} </strong> Is it possible? And in this case how do that? <strong>{{userdata.location.city + userdata.location.state + userdata.location.country }}</strong> userdata.locationi.city,state,country can be null or undefined 回答1: The solution is the same as having a default fallback for