Questions tagged [nested-statement]
12 questions
10
votes
3 answers
Nesting the ternary operator in Python
In the Zen of Python, Tim Peters states that Flat is better than nested.. If I have understood that correctly, then in Python, this:
if else
is generally preferred over this:
if :
…

LazySloth13
- 2,369
- 8
- 28
- 37
3
votes
3 answers
How to nest OR statements in JavaScript?
Currently I am creating a filemanager.
What I want is to check if the user has selected a video file. The file can be mov, f4v, flv, mp4 and swf.
I want to check if my var ext is one of these.
What I have is:
if(ext == ('mov' || 'f4v' || 'flv' ||…

Ron van der Heijden
- 14,803
- 7
- 58
- 82
3
votes
3 answers
Nested if/else, switches or something more efficient for RPG combat?
I'm developing a turn based RPG in java for android phones and I'm currently trying to figure out how to handle attacks that have extra variables beyond damage. For example, I would like to have fire attacks do an extra 10% damage when the target…

willmer
- 233
- 1
- 4
- 12
1
vote
0 answers
How to reduce cognitive complex in javascript event handler?
I have some element event handler uses if statement inside, why sonar complains this if statement causes cognitive complexity? Is there a way I can avoid this or improve this?
const handleOnBlur = () => {
if (isEditMode) {
…

spspli
- 3,128
- 11
- 48
- 75
1
vote
6 answers
Quick question about returning from a nested statement
If I have something like a loop or a set of if/else statements, and I want to return a value from within the nest (see below), is the best way of doing this to assign the value to a field or property and return that?
See below:
bool b;
public bool…

GurdeepS
- 65,107
- 109
- 251
- 387
1
vote
2 answers
C# build the if conditions at runtime
I have nested if else structure, more or less doing the same thing.
simply it's a single if(A && B && C)
but I have flag D and E for condition A and C respectively.
That means if D is false, A should be disappear and not evaluated. It's same for C…

Donald
- 33
- 6
0
votes
1 answer
how to get records of a table whose id's are taken from a select statement
I have two tables. I try to select some records from one of them. Then, ID's part of that selection should be used to select some records of the other table. For that, I wrote a statement which takes long time for execution. I even couldn't see the…

nenana
- 57
- 1
- 10
0
votes
2 answers
Conditional Vlook up in Excel
I have a table for seller name and sales
enter image description here
I am matching data for : enter image description here
For Mark I an use simple vlook up formula but for Susan it is returning see other. I want that it should look on other where…

trinity
- 1
- 1
0
votes
1 answer
How to improve SQL query performance in MySQL
I have a MySQL table which stores backup log entries from a large number of devices (currently about 750). I need to use a query to get details of the last entry for each device. I am currently using a nested query to achieve this, which was working…

Jet86
- 105
- 4
0
votes
2 answers
Nested statements in sqlite
I'm using the sqlite3 library in c++ to query the database from *.sqlite file. can you write a query statement in sqlite3 like:
char* sql = "select name from table id = (select full_name from second_table where column = 4);"
The second statement…

cpx
- 17,009
- 20
- 87
- 142
0
votes
1 answer
Nested Select ... From a simulated full outer join
So I have a query; a simulated FULL OUTER JOIN like this:
SELECT * FROM SupplierInfo
LEFT JOIN MajorEquipment ON SupplierInfo.SupplierId = MajorEquipment.MEId
UNION
SELECT * FROM SupplierInfo
RIGHT JOIN MajorEquipment ON SupplierInfo.SupplierId =…

Ben
- 2,433
- 5
- 39
- 69
0
votes
2 answers
Simple Nested SQL statement
I'm just starting to learn SQL and I have a question that may seem simple. Given the following data:
step 1 - project 1
step 2 - project 1
step 3 - project 1
step 1 - project 2
step 2 - project 2
step 1 - project 3
step 1 - project 4
step 2…

SimLaf
- 3
- 1