javascript – `void` function to replace if-else with a short-circuit expression

This is the "code in question" in the following code:

const s = "waterrfetawx";
const del = 2;
palindromePossible function (str, deleteAtMost) {
const set = new Set ();
for (let i = 0, len = str.length; i <len; i ++) {
const char = str[i];
void (set.delete (char) || set.add (char)); // <- code in question
}
return set.size <= deleteAtMost + 1;
}

The code in question can also be written like this:

if (set.has (char)) {
set.delete (char)
} other {
set.add (char)
}

I'm not too sure if empty(...) is considered "clean", that is, readable, maintainable, and clear because it encapsulates only one expression in an instruction. How would you have written better?

Void controls implicit in algorithms

I read algorithms in a CS book in which a potentially null value is passed to a function, but neither the caller nor the called party checks whether the value is zero. Is this a common practice in algorithms?

To be more precise, I implements a red-black tree and the grandparent of a node is transmitted to a rotation function, but if he correctly understands the algorithm, the large -parent may be zero at the time of the call of the rotation function.

I should probably turn such calls into a conditional block, but I was curious to know if algorithms are often specified this way and if there are additional tips on how to handle these cases.

Thank you

Simple Tic Tac Toe Game in C ++[0]After receiving a recommendation from the user Juho, I added this question to 2. I'm really new to programming, and I've made this simple tic tac toe application in python and c ++. Please tell me what can be improved Code: #understand #understand #understand using namespace std; vector toDraw {"1", "2", "3", "4", "5", "6", "7", "8", "9"}; // NOLINT (cert-err58-cpp) void reset (); void reDrawBoard (bool gameOver); int playerTurn = 1; int check (); // 0 – Game in progress; 1 – player 1 wins; 2 – the player 2 wins; int turnPlayed = 0; int main () { while (true) { reDrawBoard (false); chain entrance; int inputToInt; while (true) { input = ""; cin >> entrance; try { inputToInt = stoi (input); if (inputToInt> 9) { cout << " nInvalid Value. Try again."; cost << " nPlayer" + to_string (playerTurn) + ", Enter a number:"; Carry on; } } catch (exception and e) { cout << " nInvalid Value. Try again."; cost << " nPlayer" + to_string (playerTurn) + ", Enter a number:"; Carry on; } try { if (inputToInt == stoi (toDraw.at (static_cast)(inputToInt – 1)))) { Pause; } } catch (exception and e) { cout << "Position already occupied, please try again."; cost << " nPlayer" + to_string (playerTurn) + ", Enter a number:"; Carry on; } } if (playerTurn == 1) { draw[inputToInt – 1] = "X"; turnPlayed ++; playerTurn = 2; } other { draw[inputToInt – 1] = "O"; turnPlayed ++; playerTurn = 1; } int result = check (); if (result == 1) { reDrawBoard (true); cost << "THE PLAYER WINS !! n"; cost << "Would you like to play again? (Y/N): "; string response; cin >> answer; transform (response.begin (), response.end (), response.begin (), :: tolower); if (answer! = "y") { printf (" e[1; 1H[2J "); returns 0; } reset (); Carry on; } if (result == 2) { reDrawBoard (true); cout << "PLAYER TWO WINNER !! n"; cost << "Would you like to play again? (Y/N): "; string response; cin >> answer; transform (response.begin (), response.end (), response.begin (), :: tolower); if (answer! = "y") { printf (" e[1; 1H[2J "); returns 0; } reset (); Carry on; } if (toursPlayed == 9) { cost << "DRAW !! n"; cost << "Would you like to play again? (Y/N): "; string response; cin >> answer; transform (response.begin (), response.end (), response.begin (), :: tolower); if (answer! = "y") { printf (" e[1; 1H[2J "); returns 0; } reset (); } } } void reDrawBoard (bool gameOver) { printf (" e[1; 1H[2J "); cout << "TIC TAC TOE – Made by Khushraj (pseudo-sacred programmer) nPlayer 1 in X and player 2 is O n n | | n" + toDraw.at (0) + "|" + toDraw.at (1) + "|" + toDraw.at (2) + " n ___ | ___ | ___ n | | n" + toDraw.at (3) + "|" + toDraw.at (4) + "|" + toDraw.at (5) + " n ___ | ___ | ___ n | | n" + toDraw.at (6) + "|" + toDraw.at (7) + "|" + toDraw.at (8) + " n | | n n"; if (! gameOver) { cout << "Player" + to_string (playerTurn) + ", Enter a number:"; } / * * This prints (something similar to) – * * TIC TAC TOE – Manufactured by Khushraj * The player one is X and the player two is O * * | | * 1 | 2 | 3 * ___ | ___ | ___ * | | * 4 | 5 | 6 * ___ | ___ | ___ * | | * 7 | 8 | 9 * | | * * Player , Enter a number: * / } int check () {// 0 – Current game, 1 – Player 1 wins, 2 – Player 2 wins string un = toDraw

;
string two = toDraw[1];
string three = toDraw[2];
string four = toDraw[3];
chain five = toDraw[4];
chain six = toDraw[5];
string seven = toDraw[6];
chain eight = toDraw[7];
new string = toDraw[8];

// FOR THE PLAYER ONE
// If the player has 3X in a row, then
if ((one == "X" && two == "X" && three == "X") || (one == "X" && four == "X" && seven == "X") ||
(a == "X" && five == "X" && nine == "X") || (seven == "X" && five == "X" && three == "X") ||
(seven == "X" && eight == "X" && nine == "X") || (three == "X" && six == "X" && nine == "X") ||
(four == "X" && five == "X" && six == "X") || (two == "X" && five == "X" && six == "X")) {
returns 1;
}

// FOR PLAYER TWO
// If the player is 3 years in a row, then
if ((one == "O" && two == "O" && three == "O") || (one == "O" && four == "O" && seven == "O") ||
(a == "O" && five == "O" && nine == "O") || (seven == "O" && five == "O" && three == "O") ||
(seven == "O" && eight == "O" && nine == "O") || (three == "O" && six == "O" && nine == "O") ||
(four == "O" && five == "O" && six == "O") || (two == "O" && five == "O" && eight == "O")) {
returns 2;
}

returns 0;
}

void reset () {
turnPlayed = 0;
toDraw = {"1", "2", "3", "4", "5", "6", "7", "8", "9"};
playerTurn = 1;
}

How to fill in the void

In HTML, I would like to have something like this:

A man, a ____, a channel, panama.

I do not want underscores / underscores to be really a text entry box. What would be a good way to mark this in HTML so that it would be accessible, for example, to a screen reader? And although it is not necessary, if it is possible to say that the underline is four characters long, so much the better.

java – Change the value passed to void

In my main class, I create a Date variable that I want to modify later in another class. For that, when I create the new class, I call it like this:

calendar = new VCalendar (dateInput);

But in the VCalendar class:

public VCalendar (Date _date to return)
{
_date to return = new Date ();
}    

When I try to assign it a value in the following way, I can not and Eclipse tells me the following error:

The local _date variable to return defined in an enclosing scope must be final or effective

How can I change it?

line – Unreal c ++ Call a void from an actor with LineTrace

Im new to C ++ (use in C #) and try to call a void on an actor when he is hit by a raycast and send him the cords.
Heres the script header that tries to call "EditMesh" (near the bottom)

    #pragma once
#include "CoreMinimal.h"
#include "GameFramework / Actor.h"
#include "ProceduralMeshComponent.h"
// # include "Core.h"
#include "Chunk.generated.h"




UCLASS ()
class VOXELWARS_API AChunk: public AActor
{

GENERATED_BODY ()

public:
// Set the default values ​​for the properties of this actor
AChunk ();

protected:
// Called at the beginning or the birth of the game
virtual void BeginPlay () override;


public:
// Called each image
// virtual void Tick (float DeltaTime) override;

// UPROPERTY (EditAnywhere, BlueprintReadWrite, Category = Default)
// UMaterialInterface * TheMaterial;
UPROPERTY (EditAnywhere)
AChunk * ChunkRef;

UPROPERTY (EditAnywhere)
class UMaterialInterface * OnMaterial;

UPROPERTY (VisibleAnywhere)
UProceduralMeshComponent * mesh;
UPROPERTY (VisibleAnywhere)
int faceCount = 0;
tarray the tops;
UPROPERTY (VisibleAnywhere)
tarray triangles;
tarray the normals;
tarray UV0;
tarray tangents;
tarray vertexColors;
tarray blocks;

int worldData[16][16][16]    = {{}};
float tUnit = 0.0625;


public: void CubeTop (int x = 0, int y = 0, int z = 0, int block = 0);
public: void CubeNorth (int x = 0, int y = 0, int z = 0, int block = 0);
public: void CubeEast (int x = 0, int y = 0, int z = 0, int block = 0);
public: void CubeSouth (int x = 0, int y = 0, int z = 0, int block = 0);
public: void CubeWest (int x = 0, int y = 0, int z = 0, int block = 0);
public: void CubeBot (int x = 0, int y = 0, int z = 0, int block = 0);
public: empty cube (FVector2D texturePos);
public: void UpdateMesh ();
public: void ClearMeshData ();
public: void GenMesh ();
public: void EditMesh (int x = 0, int y = 0, int z = 0, int block = 0); //right here

public: int Chk (int x = 0, int y = 0, int z = 0);
// int * mBlock (int x = 0, int y = 0, int z = 0);
};

And here is some of the cpp from the other script that I want to call EditMesh () with

                                #include "Chunk.h"
#include "VoxelWarsCharacter.h"
#include "VoxelWarsProjectile.h"
#include "Animation / AnimInstance.h"
#include "Camera / CameraComponent.h"
#include "Components / CapsuleComponent.h"
#include "Components / InputComponent.h"
#include "GameFramework / InputSettings.h"
#include "HeadMountedDisplayFunctionLibrary.h"
#include "Kismet / GameplayStatics.h"
#include "MotionControllerComponent.h"
#include "XRMotionControllerBase.h" // for

voW AVoxelWarsCharacter :: OnFire ()
{
FVector StartLocation = GetActorLocation (); // your location
StartLocation.Z + = 15;
FVector EndLocation = StartLocation + (FirstPersonCameraComponent-> GetForwardVector () * 4000.f); // get forward dir
FHitResult Hit;
FCollisionQueryParams ColParms; // ignoring
ColParms.AddIgnoredActor (this); // do not know how to hit

GetWorld () -> LineTraceSingleByChannel (Hit, StartLocation, EndLocation, ECC_Visibility, ColParms); // ECC_WorldDynamic will only appear in Actors, ECC_Visibility is everything.

if (Hit.GetActor ()) {
//Hit.GetActor()->AChunk::EditMesh(0, 0, 0, 1);
GEngine-> AddOnScreenDebugMessage (-1, 5.f, FColor (255,255,255), "Hit an actor");
UKismetSystemLibrary :: DrawDebugLine (GetWorld (), StartLocation, Hit.Location, FColor (255, 255, 0), 5, 1); // FColor :: Red

Hit.GetActor () -> FindComponentByClass() -> EditMesh ((int) Hit.Location.X, (int) Hit.Location.Y, (int) Hit.Location.Z, 0);
// how can i do this ?????????
}
}

Errors I receive

CompilerResultsLog: Error: D: ProgramFiles Epic Games 4.19 UE_4.19 Engine Source Runtime Engine Classes GameFramework / Actor.h (2640): Error C2338: Model Parameter & # 39; T & # 39; of FindComponentByClass must be derived. UActorComponent CompilerResultsLog:

Error: C: Users nolan Office VoxelWarsUR Project VoxelWars Source VoxelWars VoxelWarsCharacter.cpp (160): Note: See the reference to the function template instantiation & # 39; T
* AActor :: FindComponentByClass (void) const while compiling

Java Selenium – Can not use Webdriver apart from "Static void main", in a different function

I use Selenium via Eclipse using Java. I have several pieces of code that I want to shorten with the help of a function. However, the driver is declared in the static void public directory. When I use the following code outside of this, it says "the driver can not be resolved." How can I fix this?

                public void TypeinField (String xpath, String Value) {
String val = value;
Element WebElement = driver.findElement (By.xpath (xpath));
element.clear ();

for (int i = 0; i <value.length (); i ++) {
char c = val.charAt (i);
String s = new StringBuilder (). Append (c) .toString ();
element.sendKeys (s);
}
}

variadic macro and variadic macro void

I know it's invalid

#define MACRO (...) __VA_ARGS__
MACRO (); // VA ARGS is empty, so is not good

However, is it valid?

#define MACRO (...)
MACRO ();