Skip to main content
0 votes
1 answer
38 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
802 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
211 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
  • 2,659
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
178 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
222 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
80 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
  • 772
1 vote
0 answers
103 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
67 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
738 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
83 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
3 votes
1 answer
117 views

Why in Java conditional expression the narrowing conversion of return type only occurs for final int and not for final short

When doing some online course, it mentioned that if we have a conditional expression in Java that returns on one side byte or short and on the other side final int, then if the int value fits into the ...
MForystek's user avatar

15 30 50 per page
1
2 3 4 5
258