Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
89 views

I am trying to better understand how the nullish coalescing operator (??) in JavaScript is supposed to work. Can someone please explain why this: let a = b ?? 0; returns this: Uncaught ...
You Old Fool's user avatar
  • 23.2k
0 votes
0 answers
30 views

I expected this assignment to work. It does not. public class Foo {} public class Bar {} internal class Program { static void Main(string[] args) { Foo? foo = null; Bar? bar ...
Joe's user avatar
  • 7,194
0 votes
1 answer
62 views

The following code works fine. What is the logic behind the addition + being evaluated after the null-coalescing ??? How's that possible? Where is the doc explaining that? int? tNullable = 2; ...
Eric Ouellet's user avatar
1 vote
1 answer
75 views

I didn't know what better title to chose for the question as I don't know what's the problem. Consider the following small C# code: static void Main(string[] args) { F1(null); } public static void ...
Gigi's user avatar
  • 330
0 votes
1 answer
93 views

I have this simple method to get a value from a wrapped DataTable: public string GetValue(int nodeID, string attributeName) { DataRow row = this.dataTable.Rows[nodeID]; var result = row.Field&...
Ondřej Janča's user avatar
-1 votes
2 answers
121 views

I am trying to reset the Session with the below code: <?= $_SESSION['pettySuccess']??''; (($_SESSION['pettySuccess']??'')=='') ?'': unset($_SESSION['pettySuccess']); ?> the idea behind my ...
achur00's user avatar
1 vote
2 answers
662 views

The issue was encountered after installing the aws s3 sdk. I followed the suggested solutions from all other similar problems in the following manner: -updated node version (even though I had version ...
SENA rajaguru's user avatar
2 votes
1 answer
226 views

The following code understandably yields "dev" when $_SERVER['MODE'] is not set: $_SERVER['MODE'] ?? null === 'production' ? 'prod' : 'dev' That is because $_SERVER['MODE'] ?? null resolves ...
Greendrake's user avatar
  • 3,754
1 vote
0 answers
773 views

I'm learning Next.JS by following the freecodecamp tutorial, and running npm run dev gives the following error output: showAll: args["--show-all"] ?? false, ^ ...
Miles's user avatar
  • 125
2 votes
2 answers
291 views

How can I write the following code in one line? private static LockSDP instance; private static readonly object _lock = new(); public static LockSDP GetInstance { ...
Oguz Demirel's user avatar
-1 votes
1 answer
533 views

I am trying to do an INSERT within PostgreSQL query but getting an error when I try to implement COALESCE operator.. What I try to accomplish is that if the id value in team_member if found, insert ...
Filip Stojavonic's user avatar
2 votes
1 answer
821 views

I've just noticed that when using throw with the null-coalescing operator, you cannot just use the keyword "throw" on its own, an exception must be included with it. The following code ...
Kevan's user avatar
  • 75
0 votes
0 answers
21 views

I'm using this line below, which works fine. My question is more for sport and curiosity than for practicality. $x = $y ?? $x; (How) could I get this even shorter in PHP? Having the $x in this line ...
Lucas Johnston's user avatar
2 votes
1 answer
323 views

if (value2 != null) { value1 = value2; } ? and ?? operators don't seem to be useful here. I thought of using the ternary operator. value1 = (value2 != null) ? value2 : value1; ...
esege's user avatar
  • 129
0 votes
1 answer
67 views

I only see use cases were null coalesing can be used to chain values, but not to omit any value. Am I missing something essential or is there really no shorthand way to write this: $model->name = &...
Alex's user avatar
  • 29
16 votes
3 answers
7k views

Php 8.0 introduced the nullsafe operator which can be used like so $foo?->bar?->baz;. I have a code sample running on php 8.1 that throws the error Undefined property: stdClass::$first_name even ...
naghal's user avatar
  • 726
1 vote
2 answers
118 views

Let's assume I have a method: private ObservableCollectionExtended<Record> myCollection; public void SetLoadingProperty(bool isLoading) { if (!myCollection?.Any() ?? false) return; ...
krs's user avatar
  • 599
1 vote
0 answers
993 views

I'm being confused as to how the null coalescing operator in PHP works and I'd like some explanation for the following if possible: I have an associative array representing data posted to the server. ...
Skye Ewers's user avatar
2 votes
0 answers
645 views

I have a nodejs API server and am using the nullish coalescing opperater. That worked great for me so far, however since today I am getting the error message newsletter: req.body.newsletter ?? ...
Christian's user avatar
  • 487
0 votes
1 answer
464 views

This is the recipe page component const RecipePages = (props) => { return ( <div> < h5 className="page-header" > Steps</h5 > <div className="...
Aditi Singh's user avatar
-1 votes
1 answer
728 views

How can I cast to one of two types in C#? Here is what I am trying to do: public class BaseCl {} public class Foo : BaseCl {} public class Bar : BaseCl {} BaseCl instance; ... some code which puts a ...
qqqqqqq's user avatar
  • 2,377
-1 votes
3 answers
75 views

Is there a way to implement the logic in my snippet? Auth::check() ?? echo "<h1>Log in please</h1>"; Parse error: syntax error, unexpected token "echo" Auth::check() ...
Rubenshtein's user avatar
0 votes
2 answers
891 views

I am populating a Class using LINQ and LinkUrl is a string property of my class.I need to set a value only if a property is not null , other wise no need to assign any values Currently The conditional ...
Sebastian's user avatar
  • 4,861
1 vote
0 answers
55 views

Is there a shortcut to the following statement? if(b!=null) a=b; The best I can come up with is a=b??a; I want to assign b to a only if b is not null, otherwise I want to leave a unchanged. The ...
programagor's user avatar
1 vote
2 answers
500 views

I'm trying to do smth like Im trying to assign property on an object if this object is not null. but standard form of non-null invocation does not work for assignment like this socket?.Blocking = ...
AnKing's user avatar
  • 2,224

1
2 3 4 5 6