Feed aggregator
Nvidia and Mistral's New Model 'Mistral-NeMo' Brings Enterprise-Grade AI To Desktop Computers
Read more of this story at Slashdot.
NASA Ends VIPER Project
Read more of this story at Slashdot.
Indian Crypto Exchange Halts Withdrawals After Losing Half Its Reserves in Security Breach
Read more of this story at Slashdot.
More Than 40% of Japanese Companies Have No Plan To Make Use of AI
Read more of this story at Slashdot.
'Supermodel Granny' Drug Extends Life In Mice By 25%, Study Finds
Read more of this story at Slashdot.
Signs of Two Gases In Clouds of Venus Could Indicate Life, Scientists Say
Read more of this story at Slashdot.
CodeSOD: False True is True False
Languages which do type-coercion are generally setting users up for failure. At some point, you'll make some assumption about your inputs, and then type-coercion kicks in and changes what you expect. We see this all the time in JavaScript, and of course, in PHP. PHP booleans, for example, can surprise you: 0 is false, which is a common enough assumption, but so is "0"- the string zero. As are empty arrays.
But what if you wanted more control over it? Peter sends us this PHP he found:
$trueFalse = array('false', 'true');This creates the trueFalse array such that it holds the strings false and true. These are, in PHP-land, both true. But let's set that aside, and look at how this array gets used:
$boolStr = @trueFalse[$some->integer->property];Yes, this is their approach to converting a boolean to a user-readable string. Which, if you don't know much about PHP, feels necessary. If you echo a boolean, it prints out as either a "1" or nothing. You need to use the function var_export, var_dump, or do an sprintf, or a ternary, a lot of other weird workarounds. But this solution also conceals another problem: a boolean variable which is true may be any nonzero value- which would break when we try and index the array by that.
I'll let Peter share his thoughts:
I actually cannot determine if this is brilliant™ or just plain stupid, but i do love the fact that the array is called trueFalse while the values in order are false and true... does that mean that true is false and false is true?
No, Peter, I don't think it means that, but I also don't think it's plain stupid. This is, despite its simplicity, advanced stupid.
[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!Psilocybin Desynchronizes the Human Brain
Read more of this story at Slashdot.
California's Grid Survives Heat Wave Thanks to Massive Battery Storage
Read more of this story at Slashdot.
'Godmother of AI' Builds $1 Billion Startup In 4 Months
Read more of this story at Slashdot.
Valve Runs Its Massive PC Gaming Ecosystem With Only About 350 Employees
Read more of this story at Slashdot.
Meta Opens Pilot Program For Researchers To Study Instagram's Impact On Teen Mental Health
Read more of this story at Slashdot.
GlobalWafers Scores $400 Million To Help Build First 300mm Wafer Plants In US
Read more of this story at Slashdot.
Meta Won't Offer Future Multimodal AI Models In EU
Read more of this story at Slashdot.
The Biggest Data Breaches In 2024: 1 Billion Stolen Records and Rising
Read more of this story at Slashdot.
Changes Are Coming To the ACT Exam
Read more of this story at Slashdot.
UK First European Country To Approve Lab-grown Meat, Starting With Pet Food
Read more of this story at Slashdot.
US To Issue Proposed Rules Limiting Chinese Vehicle Software in August
Read more of this story at Slashdot.
Leaked Docs Show What Phones Cellebrite Can and Can't Unlock
Read more of this story at Slashdot.
Google Docs is Finally Adding Markdown Support
Read more of this story at Slashdot.