mr. null
-
not sure if this was posted before: http://www.wired.com/2015/11/null/[^] the challenges of having Null as a (real) last name.
-
My thoughts exactly! It takes A LOT OF WORK to translate "null" into null... :~ At least in the languages I know. Unless...
<script>
var name = 'null';
if (name == null) {
alert("That's a lovely name " + name + '!');
} else {
alert('Please insert a name!');
}
</script>Yep, JavaScript as always X| And it's only the one language that's used for every website everywhere. Just "if (name)" would've been fine though... JavaScript... Y U DO DIS!? :confused:
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
-
Java[^] for example. But which other languages does the same?
Wrong is evil and must be defeated. - Jeff Ello
-
not sure if this was posted before: http://www.wired.com/2015/11/null/[^] the challenges of having Null as a (real) last name.
For websites and stuff to fail like that is really worrying. Shouldn't those just be strings?
What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
-
Java[^] for example. But which other languages does the same?
Wrong is evil and must be defeated. - Jeff Ello
-
My thoughts exactly! It takes A LOT OF WORK to translate "null" into null... :~ At least in the languages I know. Unless...
<script>
var name = 'null';
if (name == null) {
alert("That's a lovely name " + name + '!');
} else {
alert('Please insert a name!');
}
</script>Yep, JavaScript as always X| And it's only the one language that's used for every website everywhere. Just "if (name)" would've been fine though... JavaScript... Y U DO DIS!? :confused:
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
-
They don't do any actual conversions, it's an abstraction. The "null pointer" has been swapped for a type of its own. This works just fine as long as you're having a strongly typed language. Which JavaScript spit isn't. I did some research yesterday evening and it seems like C# does the same.
Wrong is evil and must be defeated. - Jeff Ello
-
My thoughts exactly! It takes A LOT OF WORK to translate "null" into null... :~ At least in the languages I know. Unless...
<script>
var name = 'null';
if (name == null) {
alert("That's a lovely name " + name + '!');
} else {
alert('Please insert a name!');
}
</script>Yep, JavaScript as always X| And it's only the one language that's used for every website everywhere. Just "if (name)" would've been fine though... JavaScript... Y U DO DIS!? :confused:
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
I wonder how this is handled in Typescript?
Wrong is evil and must be defeated. - Jeff Ello
-
I wonder how this is handled in Typescript?
Wrong is evil and must be defeated. - Jeff Ello
The only way to handle this is simply "if (name)"... Even "if (name === null)" evaluates to true if name is "null"! :~ And it gets worse "name === undefined" is also true for name is "null"... That's not even close! Well, undefined === null, but that's just bullcrap. As is JavaScript X|
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
-
They don't do any actual conversions, it's an abstraction. The "null pointer" has been swapped for a type of its own. This works just fine as long as you're having a strongly typed language. Which JavaScript spit isn't. I did some research yesterday evening and it seems like C# does the same.
Wrong is evil and must be defeated. - Jeff Ello
-
The only way to handle this is simply "if (name)"... Even "if (name === null)" evaluates to true if name is "null"! :~ And it gets worse "name === undefined" is also true for name is "null"... That's not even close! Well, undefined === null, but that's just bullcrap. As is JavaScript X|
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
Which flavour of javascript are you using? I've tried in Firefox, Chrome, IE11 and Edge, and I can't get it to think that
"null"
is equal tonull
orundefined
at all. :confused: Try this test script: https://jsfiddle.net/bfg9cxg2/[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Which flavour of javascript are you using? I've tried in Firefox, Chrome, IE11 and Edge, and I can't get it to think that
"null"
is equal tonull
orundefined
at all. :confused: Try this test script: https://jsfiddle.net/bfg9cxg2/[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I just realized I've switched == and !=... If stupidity hurt I'd be in agonizing pain right now! :laugh:
Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
-
Yeah, that's what I was thinking. What bassakward software is written to see a "null" STRING as a null object pointer. WTF? Very poorly written software. And I'm wondering just how real this is?
Decrease the belief in God, and you increase the numbers of those who wish to play at being God by being “society’s supervisors,” who deny the existence of divine standards, but are very serious about imposing their own standards on society.-Neal A. Maxwell You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
Java[^] for example. But which other languages does the same?
Wrong is evil and must be defeated. - Jeff Ello
Really? Java converts a string variable with the contents "null" into a null object pointer? Really? I think maybe you mean JavaScript, but even then that doesn't do what you suggest (convert a string containing "null" to a null pointer).
Decrease the belief in God, and you increase the numbers of those who wish to play at being God by being “society’s supervisors,” who deny the existence of divine standards, but are very serious about imposing their own standards on society.-Neal A. Maxwell You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
Exactly. I think Mr Jörgen is confused.
Decrease the belief in God, and you increase the numbers of those who wish to play at being God by being “society’s supervisors,” who deny the existence of divine standards, but are very serious about imposing their own standards on society.-Neal A. Maxwell You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
Which flavour of javascript are you using? I've tried in Firefox, Chrome, IE11 and Edge, and I can't get it to think that
"null"
is equal tonull
orundefined
at all. :confused: Try this test script: https://jsfiddle.net/bfg9cxg2/[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I modified it to test for "undefined == null" and "undefined === null" and only the "==" (double eq) succeeded in being "equal".
Decrease the belief in God, and you increase the numbers of those who wish to play at being God by being “society’s supervisors,” who deny the existence of divine standards, but are very serious about imposing their own standards on society.-Neal A. Maxwell You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
For websites and stuff to fail like that is really worrying. Shouldn't those just be strings?
What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
There's probably some code somewhere in the frontend/backend that's comparing the string to "null" because the developers doughheads decided that was the way to represent (no data) for certain db fields instead of using the more reasonable dbnull field concept.
Decrease the belief in God, and you increase the numbers of those who wish to play at being God by being “society’s supervisors,” who deny the existence of divine standards, but are very serious about imposing their own standards on society.-Neal A. Maxwell You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
I modified it to test for "undefined == null" and "undefined === null" and only the "==" (double eq) succeeded in being "equal".
Decrease the belief in God, and you increase the numbers of those who wish to play at being God by being “society’s supervisors,” who deny the existence of divine standards, but are very serious about imposing their own standards on society.-Neal A. Maxwell You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
But that's not the point. The test was whether the string value
"null"
would compare equal tonull
orundefined
, which it doesn't."null" === null // false
"null" == null // false
"null" === undefined // false
"null" == undefined // false// Neither of these tests would affect "Mr Null":
null === undefined // false
null == undefined // true
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
But that's not the point. The test was whether the string value
"null"
would compare equal tonull
orundefined
, which it doesn't."null" === null // false
"null" == null // false
"null" === undefined // false
"null" == undefined // false// Neither of these tests would affect "Mr Null":
null === undefined // false
null == undefined // true
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Yes, I know, and I understood that already. The claim was made that "undefined == null" and "undefined === null" are equivalent and "fail" but they don't. Both are valid well-defined statements and comparisons.
Decrease the belief in God, and you increase the numbers of those who wish to play at being God by being “society’s supervisors,” who deny the existence of divine standards, but are very serious about imposing their own standards on society.-Neal A. Maxwell You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun