Why do I get this warning when using a null conditional operator?

In the OnTriggerEnter2D function of my Bullet script, I have the following code:

private void OnTriggerEnter2D(Collider2D other) {      if (other.CompareTag("Enemy"))      {          var enemy = other.GetComponent<Enemy>();          enemy?.Death();      } } 

The reason for the null conditional operator (the question mark) in enemy?.Death() is because the Death function actually destroys the Enemy component script, so it suppresses an error when the bullet hits the enemy again. It’s supposed to be shorthand for:

if (enemy != null)     enemy.Death(); 

The code works; the error is suppressed. However, the IDE that I’m using, Jetbeans Rider, gives the following warning:

‘?.’ on a type deriving from ‘UnityEngine.Object’ bypasses the lifetime check on the underlying Unity object.

What does that mean exactly? Should I continue using the null conditional operator?

Using conditional logic on fields in gravity form based on Paid Memberships Pro membership level

I’m trying to use conditional logic to hide/show fields in my gravity form based on user’s membership level determined by Paid Memberships Pro. I’ve tried all different variations using {user:membership_level} in a hidden field. Then, using conditional logic on selected fields, I’ve tried to hide/show based on the value of the membership level.

Any help would be appreciated. Is my meta key ({user:membership_level}) incorrect?

How do you calculate an average damage when damage is conditional on circumstances?

I’m trying to compare two rogue builds to each other. The first rogue is easy. It’s a wood elf with a long bow in a wilderness campaign, doing 1d8+mod damage and always being hidden with SA damage. Fine. My second rogue however is a dungeoneering halfling who might use a rapier, or might use a short sword and a dagger in the off hand.

What I’m trying to figure out is how to calculate the average damage with five different possible scenarios in mind. Each scenario might be used depending on the circumstances: who’s in the room, what obstacles are there, etc.

  1. Shortsword(d6+3) + cunning action + SA(d6) (advantage) = (9)
  2. Shortsword(d6+3) + dagger(d4) + SA(d6) (no advantage) = (7.5)
  3. Rapier(d8+3) + cunning action + SA(d6) (advantage) = (9.9)
  4. Shortsword(d6+3) + dagger(d4) (no SA available) = (5.4)
  5. Shortsword(d6+3) + dagger(d4) + SA(d6) (advantage) = (11.25)

How do I figure out the odds of each of those 5 scenarios – just do average damage compiled then divided by 5? And how do I get a final reasonable number?

So does this become (9 + 7.5 + 9.9 + 5.4 + 11.25)/5 = 8.61 at level 1?

How would you compile an conditional accumulation?

How to FunctionCompile this:

Function[x,  If[IntegerQ @ Sqrt[80892036 + 17994 x (1 + x) (-5995 + 5998 x)], x,    Nothing] /@ Range[6694300, 31072325] 

I don’t know much about FunctionCompile, how to handle Nothion, do bags work for accumulating, if so how does one Type them?

What I’ve tried:

na = NumericArray[Range[6694300, 31072325], "UnsignedInteger32"];  doit = FunctionCompile[    Function[{Typed[arg,        TypeSpecifier["NumericArray"]["UnsignedInteger32", 1]]},     Module[{       f =         Typed[Function[Typed[x, "UnsignedInteger32"],           Sqrt[80892036 + 17994 x (1 + x) (-5995 + 5998 x)]],          "UnsignedInteger32" -> "Real64"];       iq =         Typed[KernelFunction[IntegerQ[f[#]] &], {"Real64"} ->           "Boolean"]},      If[iq@#, #, Nothing] & /@ arg      ]]]; doit[na] 

Can an end-user modify conditional rendering in React?

On my Single Page App I am using MSAL.js to authenticate users and to also extract the groups they belong to by using Microsoft Graph endpoints. I save to a variable the Specific groups the user belongs to. According to the content of that variable, a different Home Page will be rendered. The code looks like this:

if (user.group == 'AppAdmin') {     return (         <div className='h1'> Admin Dashboard</div>     ); } else if (user.group == 'AppManager') {     return (         <div className='h1'> App Manager Dashboard</div>     ); } else {     return (         <div className='h1'> User Dashboard</div>     ); } 

user.group contains the group the user belongs to in Active Directory.

Will an end user not belonging to the AppAdmin or AppManager groups be able to modify in their web browser the variable user.group value to fool the browser into rendering admin or manager content?

MongoDB conditional set

I’m using MongoDB + Mongoose + Node.JS

App logic: We have a game similar to minesweeper. User selected cells in game field store in fields: Array, and bombs locations store in bombs: Array.

When user performing a request to select a cell in game, server must set fields[cell] = 1 // 1 means cell is selected. If the bomb in cell bombs[cell] === 1 // 1 means bomb in cell we need to make different update, like fields[cell] = 1; winning = 0. How to realize it in one query?

I tried to make a query, wich change only field[cell] = 1, but don’t change winning = 0 if inside field detected bomb.


const selection = await db.Minesweeper.findOneAndUpdate({     uid,     winning: null, }, {     $  set: { [`fields.$  {cell}`]: 1, },     // I need to set winning = 0, if [bombs.$  {cell}] = 1 }); 

Game schema:

const MinesweeperSchema = new mongoose.Schema({     uid: { type: Number, required: true },     bet: { type: Number, required: true },     winning: { type: Number, default: null },     fields: { type: Array, default: new Array(5*5).fill(0) },     bombs: { type: Array, required: true }, }, { timestamps: true }); 

Well, again:

I need that logic: If selected cell contains a bomb, set field[cell_index] = 1; winning = 0, but if cell don’t contains a bomb, set field[cell_index] = 1

Decoding problem and conditional probabilities

I’m reading the book by MacKay “Information theory, inference and learning algorithms” and I’m confused by how he introduces the decoding problem for LDPC codes (page 557).

given a channel output $ \mathbf{r}$ , we wish to find the codeword $ \mathbf{t}$ that whose likelihood $ P(\mathbf{r}|\mathbf{t})$ is biggest.

I can get on board with that, even if it seems a bit backwards since $ \mathbf{r}$ is the evidence we have, so I would be more comfortable if we were trying to find $ \mathbf{t}$ that maximizes $ P(\mathbf{t}|\mathbf{r})$ , and as a matter of fact, he goes on to say

there are two approaches to the decoding problem both of which lead to the generic problem ‘find $ \mathbf{x}$ that maximizes $ $ P^*(\mathbf{x})=P(\mathbf{x})\mathbb{1}[\mathbf{Hx}=\mathbf{z}]$ $

he exposes the two points of view in the following page, the first one especially confuses me

the codeword decoding point of view

First, we note the prior distribution over codewords $ $ P(\mathbf{t})=\mathbb{1}[\mathbf{Ht}=\mathbf{0}]$ $ […]. The posterior distribution over codewords is given by multiplying the prior by the likelihood […] $ $ P(\mathbf{t}|\mathbf{r})\propto P(\mathbf{t})P(\mathbf{r}|\mathbf{t}) $ $

from the generic decoding problem he gave, it looks like we’re actually trying to maximize $ P(\mathbf{x})=P(\mathbf{t}|\mathbf{r})$ , instead of $ P(\mathbf{r}|\mathbf{t})$ .

Is it obvious that the two maxima are the same and with the same maximizer? It is not obvious to me since the maximizer $ \mathbf{t_0}$ that maximizes $ P(\mathbf{r}|\mathbf{t})$ might actually minimize $ P(\mathbf{t})$ , so the maximizer of $ P(\mathbf{t})P(\mathbf{r}|\mathbf{t})$ might be different! I understand that in this case $ P(\mathbf{t})$ is uniform, so this shouldn’t be a problem, but it seems weird to me that this is simply not stated and I feel like I’m missing something.

Why should we start with the problem of maximizing $ P(\mathbf{r}|\mathbf{t})$ and not $ P(\mathbf{t}|\mathbf{r})$ ? Why does he seem to switch after a few sentences? Am I correct in thinking the algorithm presented actually maximizes $ P(\mathbf{t}|\mathbf{r})$ ?

Thank you

How does derandomization of (1-1/e) factor algorithm of MAX-SAT work with conditional expectations?

I am attempting to understand how to show that the (1-1/e) factor algorithm for MAX-SAT can be derandomized with conditional expectations.

Similar to the 1/2 factor algorithm, I have attempted a greedy approach, scanning across each literal x_i, from x_1 to x_n, and setting each literal to true or false depending on which results in the greatest total expectation. However I am struggling to show how the total expectation at each step of this approach is at least as great as the total expectation of the previous step.

I would appreciate any insight on how to proceed.