Skip to main content

All Questions

1 vote
3 answers
95 views

How to add multiple children based on single ternary operator in Flutter Row

How to add multiple children based on single ternary operator in Flutter Row? Row( children: [ Widget1(), n.type != null ? { Icon( Icons.access_time, size: 14, ...
Pulkit Goyal's user avatar
0 votes
1 answer
41 views

How to model a many-to-many relationship in DynamoDB with composite keys and enforce unique (id, ruleId) pairs?

I have a DynamoDB table defined as follows: Partition key: id (string) Sort key: ruleId (string) Example item: { "id": "123", "ruleId": "abc" } What I want is ...
Maayan Israel's user avatar
5 votes
0 answers
174 views

When is the ternary operator suitable for copy elision? [duplicate]

According to this article by Raymond Chen, ternary expression is not a copy elision candidate. The problem with the ternary is that the ternary expression is not a copy elision candidate. The rule ...
許恩嘉's user avatar
  • 1,263
14 votes
1 answer
805 views

Copy constructor is called with result of rvalue conditional operator

According to cppreference, value category of conditional operator in C++ depends on categories of the operands, namely: if both operands are lvalues, then conditional operator is also lvalue, ...
TDjey's user avatar
  • 165
1 vote
1 answer
214 views

Why ternary operator cannot be used for this statement? [duplicate]

This code gives me compiler error: "expected an expression". std::array< std::string, 3 > candidates = useOutname ? { "%O.log", "%O_.log", "_%O.log" } : { ...
PkDrew's user avatar
  • 1
0 votes
1 answer
61 views

Ternary operator initialization producing incorrect static type [duplicate]

I'm perplexed by the vscode hover hints and tsc (v5.8.3) messages I am seeing as I initialize a variable with a ternary expression that might return my trivial custom class. They seem to incorrectly ...
user3624334's user avatar
5 votes
2 answers
181 views

How does the `(…) and (…) or (…)` idiom mimic a ternary operator in Lua?

This statement mimics a ternary operator in the Lua programing language: local result = condition and true_value or false_value But how does it work? Why does it give true_value if the condition is ...
0747's user avatar
  • 55
4 votes
1 answer
115 views

Error using ternary operator and method overloading of wrapper class in Java 8 only

I am using Java 8 and facing some weird error. The compiler gives the following error: error: reference to [method] is ambiguous Here's my code StringBuilder sb = new StringBuilder(); Stack<...
bloop's user avatar
  • 43
0 votes
1 answer
237 views

nunjucks ternary if expression

I'm using nunjucks as a templating engine in my application and can't seem to get the block to display at all when I apply more than two conditions e.g. {{ "true" if foo else "false&...
Haggishunt56's user avatar
0 votes
1 answer
91 views

pandas dataframe select rows with ternary operator

My requirement is simple, I need to select the rows from a Pandas DataFrame when one of two couple columns are populated or both. The attributes contain integer foreign keys. This works: ...
KBD's user avatar
  • 141
1 vote
1 answer
81 views

How do conditional expressions group from right to left?

I checked python operator precedence (This one grammar is more detailed and more appropriate for the actual Python implementation) Operators in the same box group left to right (except for ...
An5Drama's user avatar
  • 782
1 vote
0 answers
106 views

conditional operator with derived and base classes with conversion operator to built-in types issue, compiler bug?

This example: struct X {}; struct Y : X {}; using CY = const Y; true ? X() : CY(); // error Which is explained in this answer, could be changed like this: struct X { operator int() { return 0; } }; ...
Sneed Deens's user avatar
3 votes
0 answers
69 views

conditional operator: inconsistency between implicit conversion sequence used for different compilers

This is a follow-up of this question: conditional operator expression with base and const derived class doesn't compile, why?. The core is cond ? [cv] T1() : [cv] T2() where, for instance T2 ...
Oersted's user avatar
  • 3,479
0 votes
2 answers
740 views

What does perl substitution operator return when applied to a string?

I can't understand what does the perl substitution return after applied. I have the following snippet my $w = "-foo"; my $v = $w =~ s/-//?0:1; print "---- $v\n"; If $w is -foo,...
smith's user avatar
  • 311
0 votes
1 answer
84 views

Shorthand nullable variable assignment in C# [duplicate]

In my C# WPF project I am trying to assign a value to nullable short with the shorthand function: short? var = (textbox.Text.Length > 0) ? short.Parse(textbox.Text) : null; Visualstudio does not ...
Malte's user avatar
  • 3

15 30 50 per page
1
2 3 4 5
258