Questions tagged [conditional-execution]
21 questions
147
votes
22 answers
Last iteration of enhanced for loop in java
Is there a way to determine if the loop is iterating for the last time. My code looks something like this:
int[] array = {1, 2, 3...};
StringBuilder builder = new StringBuilder();
for(int i : array)
{
builder.append("" + i);
…

Mercurious
- 3,228
- 6
- 24
- 20
31
votes
7 answers
Why are conditionally executed instructions not present in later ARM instruction sets?
Naively, conditionally executed instructions seem like a great idea to me.
As I read more about ARM (and ARM-like) instruction sets (Thumb2, Unicore, AArch64) I find that they all lack the bits for conditional execution.
Why is conditional execution…

fadedbee
- 42,671
- 44
- 178
- 308
16
votes
2 answers
python conditional debug breakpoint one-liner for versions before 3.7 PEP 553 that acts similarly to Perl's $DB::single=1
In python versions before PEP 553 breakpoint() utility, what is the recommended way to add (ideally a one-liner) code to have a breakpoint that can be ignored upon a condition (e.g. a global debug flag or args.debug flag).
In Perl, I am used to use…

719016
- 9,922
- 20
- 85
- 158
7
votes
2 answers
Maven - How to perform conditional execution
Is there a way to perform conditional execution of snippet in pom.xml?
my requirement is to copy a file/directory to deploy structure based on variable defined in pom.xml...
eg:
< if >
< equals arg1="package" arg2="package"/>
< then>
…

user1450759
- 71
- 1
- 1
- 2
3
votes
2 answers
Chaining completable futures based on conditions
I am having a bunch of methods that return a CompletableFuture and I would like to chain in a specific way
package com.sandbox;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.stream.IntStream;
public class…

g0c00l.g33k
- 2,458
- 2
- 31
- 41
3
votes
2 answers
How to pass conditional children in React / Preact (aka. component)
Sometimes I need to create a wrapper element that will show its children (or not) according to its own logic, optionally wrapping them in its own choice of elements:
Hello
This works because the…

Tobia
- 17,856
- 6
- 74
- 93
2
votes
1 answer
How to run some code based on release or debug build mode?
I have a variable(i.e bool releaseMode = false;)
I want the value of the variable to be set based on whether we are in release mode(releaseMode = true;) else debug mode(releaseMode = false;)

shahab jani
- 88
- 5
2
votes
2 answers
How to conditionally add a pipeline element in bash
I need to form a pipeline of various commands. Some elements of the pipeline, or sequences of elements, are only relevant when some condition holds. Now, I could write:
if [[ $whatever ]]; then
cmd1 | cmd2 | cmd3 | cmd4
else
cmd1 |…

einpoklum
- 118,144
- 57
- 340
- 684
2
votes
3 answers
Why does Java not optimize |= assignments?
t*() always returns true for this example, where as f*() always returns false.
Let's say we have the following expression
if ( f1() || t1() || f2() || t2() ){
// do stuff
}
If this is the case the JVM optimizes the execution and only…

товіаѕ
- 2,881
- 4
- 23
- 53
1
vote
1 answer
Maven profile not activated, though property has correct value
I am trying to set-up conditional plugin execution via profiles. The idea is to have a compress/no compress HTML files:

Jérôme Verstrynge
- 57,710
- 92
- 283
- 453
1
vote
3 answers
failed command in pipeline not triggering "catch" command
I am trying to set up a small block of code so that if any piece of it fails, it will trigger another line of code to be run. So like:
cmd1 || cmd2
However, the first segment has a pipe in it, so:
cmd1 | cmd2 || cmd3
However, if cmd1 fails, cmd3…

Batcastle
- 170
- 12
1
vote
5 answers
Conditional execution of a method using annotation
In java can I have conditional execution of a method using annotations?
I wish to have some system property set and based on that system property I wish to either execute or not execute a method (specifically ant script based JUnits) at…

celeritas
- 398
- 1
- 4
- 16
0
votes
3 answers
Conditional command execution within piped sequence of commands in bash
Sorry for bumpy topic name (feel free to edit if you find more fitting title after looking at problem).
Code sample equals 1000 words, so here we go:
if [ "$REGEX" != "" ]; then
find $TEST_DIR -type f -regextype posix-extended -regex…

Tomas Pruzina
- 8,397
- 6
- 26
- 39
0
votes
1 answer
PDF autofill using javascript nested if statement error
I have a pdf with two input text boxes. 1.) Item Code and 2.) Item
I am trying to populate "Item" based on "item code" but the nested statements are giving me data for the first else if condition below for all cases. For example, I should get "20%…

Susie Dent
- 73
- 2
- 6
0
votes
1 answer
How does conditional jump of x86-64 works?
I'm so confused about conditional branch while I was studying x86-64.
compq %rax,%rdi
jl .L2
Which one is the correct understanding?
if %rax < %rdi, jump to L2
if %rax > %rdi, jump to L2

김동령
- 3
- 2